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

Popular posts from this blog

sublimetext3 - what keyboard shortcut is to comment/uncomment for this script tag in sublime -

java - No use of nillable="0" in SOAP Webservice -

ubuntu - Laravel 5.2 quickstart guide gives Not Found Error -