How to update/Insert random dates in SQL within a specified Date Range

后端 未结 2 784
情歌与酒
情歌与酒 2021-01-25 23:12

Please forgive me. I am an absolute newbie and I need help with this table in phpmyadmin

My Table has the following columns:

Primary_ID, Begin_Date, End_         


        
2条回答
  •  面向向阳花
    2021-01-25 23:53

    something like:

    insert into myTable (begin_date) values date_add('2008-09-01', INTERVAL RAND()*30 DAY)

    that should create a new row with a random begin_date

    update myTable set Timestamp = date_add(begin_date, INTERVAL RAND()*1440 MINUTE)

    then that one should set the timestamp to a random minute of that day.

提交回复
热议问题