Random Date Generation

The simplest way to populate your database with test data.

Moderators: David Atkinson, Anu Deshpande, Lionel

Random Date Generation

Postby batdan@libero.it » Mon Apr 12, 2010 3:19 pm

Hi all,
there is a method to generate random date time from a valid range?
If exists only the Regex method wich is the right regex expression to generate valid date?
Thank's
batdan@libero.it
 
Posts: 2
Joined: Mon Apr 12, 2010 3:13 pm

Postby peter.peart » Wed Apr 14, 2010 4:24 pm

Hi there,

Many thanks for your post, although I am not entirely sure what you are looking for I am afraid.

SQL Data Generator will generate a date / time which is random on any column that uses the datetime datatype. From here, you can then choose the minimum and maximum date and select to randomize the time, without the need to use a regex.

Pete[/img]
Peter Peart
Red Gate Software Ltd
+44 (0)870 160 0037 ext. 8569
1 866 RED GATE ext. 8569
peter.peart
Site Admin
 
Posts: 362
Joined: Tue Sep 02, 2008 9:58 am
Location: Top floor, RG towers with the cool kids

Postby batdan@libero.it » Wed Apr 14, 2010 4:38 pm

Sorry for my english.

The problem is that i don't have a datetime datatype. I have a varchar column.
It's possible to generate random DateTime between a range in varchar column? If Yes how to do this?
How to generate DateTime in a DateTime column?
Many thank's
batdan@libero.it
 
Posts: 2
Joined: Mon Apr 12, 2010 3:13 pm

Postby peter.peart » Wed Apr 14, 2010 4:49 pm

Hi there,

If you have a varchar column then you will indeed have to use a regex. Something like this will work, although provides dates a fair way back into the past and into the future:

(0[1-9]|[12][0-9]|3[01])[/](0[1-9]|1[012])[/](19|20)[0-9]{2}

It should be enough to get you going hopefully though!

HTH!

Pete
Peter Peart
Red Gate Software Ltd
+44 (0)870 160 0037 ext. 8569
1 866 RED GATE ext. 8569
peter.peart
Site Admin
 
Posts: 362
Joined: Tue Sep 02, 2008 9:58 am
Location: Top floor, RG towers with the cool kids


Return to SQL Data Generator 1

Who is online

Users browsing this forum: No registered users and 1 guest