Random Date Generation

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

Comments

  • 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
  • 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
  • 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
Sign In or Register to comment.