Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 
mwallman
Creator III
Creator III

How to generate a random date in a 150 day range before a Start Date?

Hi all,

How to generate a random date in a 150 day range before a Start Date?

I believe I can use the Rand() function but I am not sure how to set it so that from the Start Date field it can generate any date 150 before the start date.

Any help please?

3 Replies
swuehl
MVP
MVP

Maybe something like

LOAD *,

          Date(StartDate-Ceil(RAND()*150)) as RandomDate

LOAD StartDate

FROM ...;

sunny_talwar

Something like this:

LOAD Date(Today() - Ceil(Rand() * 150)) as Date

Replace Today() with your Start Date

jyothish8807
Master II
Master II

Hi Michael,

Try like this:

let vStartdate= num(today());

Temp_date:

load date($(vStartdate)+rowno()-1) as New_Date

AutoGenerate 150;

or

let vStartdate= num(today());

Temp_date:

load date($(vStartdate)+Ceil(Rand() * 150)) as New_Date

AutoGenerate 150;

Regards

KC

Best Regards,
KC