Welcome to the Tweaking4All community forums!
When participating, please keep the Forum Rules in mind!
Topics for particular software or systems: Start your topic link with the name of the application or system.
For example “MacOS X – Your question“, or “MS Word – Your Tip or Trick“.
Please note that switching to another language when reading a post will not bring you to the same post, in Dutch, as there is no translation for that post!
[Solved] MySQL: Fill field with random dates (quick and dirty)
(@hans)
Famed Member Admin
Joined: 12 years ago
Posts: 2859
Topic starter
July 15, 2013 7:59 AM
I had to fill a tablefield with some quick random dates for testing purposes and ran into this little gem:
(it fills the field for each record with a random date between January 1 and June 28 2013)
(source)
update project_management
set prj_first_activated = str_to_date(
concat(
floor(1 + rand() * (6 - 1)), /* Generate a random month */
'-',
floor(1 + rand() * (28 -1)), /* Generate a random day */
'-',
'2013'
),
'%m-%d-%Y'
);
Hope somebody has a use for it as well ...