Here’s yet another way:
Code:
UPDATE tableName
SET column = FROM_UNIXTIME(RAND() * (UNIX_TIMESTAMP(‘2015-7-20 15:00:00′) – UNIX_TIMESTAMP(‘2008-09-10 12:00:00′)) + UNIX_TIMESTAMP(‘2008-09-10 12:00:00′));
This will set the column’s value to a random datetime between ‘2015-7-20 15:00:00′ and ‘2008-09-10 12:00:00′.
If you only have a DATE field, you can extract the date from the end result. For example:
Code:
UPDATE tableName
SET column = DATE(FROM_UNIXTIME(RAND() * (UNIX_TIMESTAMP(‘2015-7-20 15:00:00′) – UNIX_TIMESTAMP(‘2008-09-10 12:00:00′)) + UNIX_TIMESTAMP(‘2008-09-10 12:00:00′)));
The time part of the value is not required, so one could do UNIX_TIMESTAMP(‘2025-01-05′) without worry.
Good luck!