Random Date generation in teradata with the help of start date and end date

Database
Enthusiast

Random Date generation in teradata with the help of start date and end date

Hi,

Help me in generating random date i.e any date between 03 sep 2010 to 07 sep 2010 by giving 03 sep 2010 as start date and 07 sep 2010 as end date
3 REPLIES
Senior Apprentice

Re: Random Date generation in teradata with the help of start date and end date

select date '2010-09-03' + random(0,4)

Dieter
Enthusiast

Re: Random Date generation in teradata with the help of start date and end date

Hi Dieter,
I will not be knowing the difference between the dates i.e. i will not know the value 4

can u pls alter the following query so that it will be useful for me

select date '2010-09-03' + random(0,(date '2010-09-07')-(date '2010-09-03') )

can u pls alter the above query so that it will work

Senior Apprentice

Re: Random Date generation in teradata with the help of start date and end date

RANDOM only accepts literal values, but this will work:

start_date + (random(0,1000000000) mod ((end_date-start_date)+1))

Dieter