[MySQL] How to create a random day for a date
If you have extracted with PHP or a SQL function a date (“YYYY-MM-DD”) and you want to change the day with a random day, here is it a series of SELECT for doing it:
SELECT date FROM (
-- generates a number x between 1 and 27
SELECT @rand:=(
SELECT FLOOR(1 + (RAND() * 27))
) as rand,
DATE_ADD('2006-05-01',INTERVAL @rand DAY) as date
) as t; -- give an alias, otherwise it's uncorrect