mysql> show create table ClientActionTrack\G;
*************************** 1. row ***************************
       Table: ClientActionTrack
Create Table: CREATE TABLE `ClientActionTrack` (
  `sn` bigint(20) NOT NULL AUTO_INCREMENT,
  `clientSn` int(11) DEFAULT NULL,
  `ip` varchar(32) DEFAULT NULL,
  `url` varchar(1000) DEFAULT NULL COMMENT 'request url',
  `httpMethod` varchar(100) DEFAULT NULL COMMENT 'http method',
  `requestParams` text COMMENT '请求参数',
  `requestHeader` varchar(2000) DEFAULT NULL COMMENT '请求头信息',
  `pageUrl` varchar(500) DEFAULT NULL COMMENT '页面Url',
  `sessionId` varchar(100) DEFAULT NULL COMMENT 'session的Id',
  `startTime` datetime NOT NULL DEFAULT '0000-00-00 00:00:00' COMMENT '访问开始时间',
  `completeTime` datetime DEFAULT NULL COMMENT '访问完成时间',
  PRIMARY KEY (`sn`,`startTime`)
) ENGINE=InnoDB AUTO_INCREMENT=10251622 DEFAULT CHARSET=utf8 COMMENT='用户访问记录表'
/*!50100 PARTITION BY RANGE (TO_DAYS(startTime))
(PARTITION p20151124 VALUES LESS THAN (736292) ENGINE = InnoDB,
 PARTITION p20151125 VALUES LESS THAN (736293) ENGINE = InnoDB,
 PARTITION p20151126 VALUES LESS THAN (736294) ENGINE = InnoDB,
 PARTITION p20151127 VALUES LESS THAN (736295) ENGINE = InnoDB,
 PARTITION p20161221 VALUES LESS THAN (736685) ENGINE = InnoDB,
 PARTITION p20161222 VALUES LESS THAN (736686) ENGINE = InnoDB,
 PARTITION p20161223 VALUES LESS THAN (736687) ENGINE = InnoDB,
 PARTITION p20161224 VALUES LESS THAN (736688) ENGINE = InnoDB,
 PARTITION p20161225 VALUES LESS THAN (736689) ENGINE = InnoDB,
 PARTITION p20161226 VALUES LESS THAN (736690) ENGINE = InnoDB,
 PARTITION p20161227 VALUES LESS THAN (736691) ENGINE = InnoDB,
 PARTITION p20161228 VALUES LESS THAN (736692) ENGINE = InnoDB,
 PARTITION p20161229 VALUES LESS THAN (736693) ENGINE = InnoDB,
 PARTITION p20161230 VALUES LESS THAN (736694) ENGINE = InnoDB,
 PARTITION p20161231 VALUES LESS THAN (736695) ENGINE = InnoDB,
 PARTITION pmax VALUES LESS THAN MAXVALUE ENGINE = InnoDB) */
1 row in set (0.21 sec)

ERROR: 
No query specified


 PARTITION p20161226 VALUES LESS THAN (736690) ENGINE = InnoDB,
 
 mysql> select TO_DAYS('2016-12-26 23:59:59') from  Client limit 1; 
+--------------------------------+
| TO_DAYS('2016-12-26 23:59:59') |
+--------------------------------+
|                         736689 |
+--------------------------------+
1 row in set (0.08 sec)


mysql> select TO_DAYS('2016-12-27 00:00:00') from  Client limit 1;
+--------------------------------+
| TO_DAYS('2016-12-27 00:00:00') |
+--------------------------------+
|                         736690 |
+--------------------------------+
1 row in set (0.00 sec)

 mysql> select startTime from ClientActionTrack limit 10;
+---------------------+
| startTime           |
+---------------------+
| 2016-06-16 18:43:53 |
| 2016-06-16 18:43:53 |
| 2016-06-16 18:43:53 |
| 2016-06-16 18:43:53 |
| 2016-06-16 18:43:53 |
| 2016-06-16 18:43:53 |
| 2016-06-16 18:43:53 |
| 2016-06-16 18:43:53 |
| 2016-06-16 18:43:53 |
| 2016-06-16 18:43:53 |
+---------------------+
10 rows in set (0.02 sec)


mysql> select TO_DAYS('2016-12-27 00:00:00') from  Client limit 1;
+--------------------------------+
| TO_DAYS('2016-12-27 00:00:00') |
+--------------------------------+
|                         736690 |
+--------------------------------+
1 row in set (0.00 sec)

mysql> select TO_DAYS('2016-12-27') from  Client limit 1;
+-----------------------+
| TO_DAYS('2016-12-27') |
+-----------------------+
|                736690 |
+-----------------------+
1 row in set (0.00 sec)



zabbix:/root/sbin# perl t2.pl  20160101 20161231 ^C
zabbix:/root/sbin# cat t2.pl 
use DBI;
use HTTP::Date qw(time2iso str2time time2iso time2isoz);
my $ip="127.0.0.1";
my $user="root";
my $passwd="1234567";
my $dbh = DBI->connect("dbi:mysql:database=$message;host=$ip;port=3306",$user,$passwd) or die "can't connect to database ". DBI-errstr;
##防止utf-8中文乱码
$dbh->do("SET NAMES utf8");
my $date1= "$ARGV[0]";
my $date2="$ARGV[1]";
my $date=$date1;
my $tip='+1';
 sub get_date{ 
       my $var_date=$_[0]; 
       my $hostSql = qq{  SELECT DATE_FORMAT( DATE_ADD( '$var_date', INTERVAL $tip  DAY), '%Y%m%d') AS xxx FROM information_schema.tables a limit 1;};
       my ($a1, $a2, $a3,$a4,$a5,$a6,$a7,$a8,$a9);    
       my $selStmt = $dbh->prepare($hostSql);    
       $selStmt->execute();    
       while (@recs=$selStmt->fetchrow_array) {
       foreach (@recs)
       {$date=$_;return $date}
};
};

 sub trans_date {
      my $var_date=shift;
      $selStmt=$dbh->prepare("select to_days('$var_date');");
     $selStmt->execute;
     while (@recs=$selStmt->fetchrow_array) {
     foreach (@recs)
       {$date=$_;return $date}
        }  
 };
    while (1==1){
    $date3=$date;
    
    $date4=&get_date($date3);
    $var=&trans_date($date4);
    print "alter table ClientActionTrack add partition (partition p$date3 values less than ($var));\n";
    $date=&get_date($date3);
    if ( "$date" == "$date2" ){$var=$var+1;print "alter table ClientActionTrack add partition (partition p$date values less than ($var))\n";$date="$date1";last;}
   };
zabbix:/root/sbin# perl t2.pl  20160101 20161231 
alter table ClientActionTrack add partition (partition p20160101 values less than (736330));
alter table ClientActionTrack add partition (partition p20160102 values less than (736331));
alter table ClientActionTrack add partition (partition p20160103 values less than (736332));
alter table ClientActionTrack add partition (partition p20160104 values less than (736333));
alter table ClientActionTrack add partition (partition p20160105 values less than (736334));
alter table ClientActionTrack add partition (partition p20160106 values less than (736335));