首页  编辑  

求给定两个日期之间的随机日期

Tags: /MySQL/   Date Created:

sql update random between two dates

SET @MIN = '2013-01-07 00:00:00';

SET @MAX = '2013-12-24 00:00:00';

UPDATE `ps_blog_post`

SET `time_add` =  TIMESTAMPADD(SECOND, FLOOR(RAND() * TIMESTAMPDIFF(SECOND, @MIN, @MAX)), @MIN);