update mysql date random between two dates -
how update in phpmyadmin sql box date field formatted 13-01-1980 random date between 2 dates, such as, day between 01-01-1990 , 01-01-1995 ?
i read many answers here on stackoverflow , elsewhere nothing worked me.
you use date arithmetic rand()
:
select date_add(date('1990-01-01'), interval cast(rand() * datediff('1995-01-01', '1990-01-01') int) day)
edit:
for update
, same logic:
update t set col2 = date_add(date('1990-01-01'), interval cast(rand() * datediff('1995-01-01', '1990-01-01') int) day) col = 'abc';
Comments
Post a Comment