Red Gate forums :: View topic - Random Date Generation
Return to www.red-gate.com RSS Feed Available

Search  | Usergroups |  Profile |  Messages |  Log in  Register 
Go to product documentation
SQL Data Generator 1
SQL Data Generator 1 forum

Random Date Generation

Search in SQL Data Generator 1 forum
Post new topic   Reply to topic
Jump to:  
Author Message
batdan@libero.it



Joined: 12 Apr 2010
Posts: 2

PostPosted: Mon Apr 12, 2010 3:19 pm    Post subject: Random Date Generation Reply with quote

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
Back to top
View user's profile Send private message
peter.peart
Site Admin


Joined: 02 Sep 2008
Posts: 362
Location: Top floor, RG towers with the cool kids

PostPosted: Wed Apr 14, 2010 4:24 pm    Post subject: Reply with quote

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
Back to top
View user's profile Send private message Send e-mail
batdan@libero.it



Joined: 12 Apr 2010
Posts: 2

PostPosted: Wed Apr 14, 2010 4:38 pm    Post subject: Reply with quote

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
Back to top
View user's profile Send private message
peter.peart
Site Admin


Joined: 02 Sep 2008
Posts: 362
Location: Top floor, RG towers with the cool kids

PostPosted: Wed Apr 14, 2010 4:49 pm    Post subject: Reply with quote

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
Back to top
View user's profile Send private message Send e-mail
Display posts from previous:   
Reply to topic All times are GMT + 1 Hour
Page 1 of 1

 
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group