标签:
20150510 给表中插入随机日期add_time(int) ,2014间随机日期,最好每个月都有
由于存储的是时间戳格式,一个月相差2678400,一天相差86400
用到的函数
SELECT UNIX_TIMESTAMP(‘20141231‘) #1419955200
SELECT FROM_UNIXTIME(1391675501,‘%Y%m%d %H:%i:%s‘)
SELECT FLOOR(1 + (RAND() * 12)) #随机月份
SELECT FLOOR(1 + (RAND() * 31)) #随机天数
SELECT FLOOR(1 + (RAND() * 86400)
UPDATE `hhy_store_copy` SET add_time= (SELECT 1419955200-(FLOOR(1 + (RAND() * 12))*2678400)-(FLOOR(1 + (RAND() * 31))*86400)-FLOOR(1 + (RAND() * 86400))) WHERE add_time IS NULL
标签:
原文地址:http://my.oschina.net/maintenance/blog/412956