Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 
Not applicable

AutoGenerate

Hi

How generate 10 Random Date between 2 Dates

4 Replies
oknotsen
Master III
Master III

First get the two dates in a variable.

Calculate the difference.

let vStartDate = num(date#('1-1-2016', 'D-M-YYYY'));
let vEndDate = num(date#('6-3-2016', 'D-M-YYYY'));
let vNumberOfDates = $(vEndDate) - $(vStartDate) + 1;

Create a table (using AutoGenerate) in which you randomly general number and multiply that by the difference.

theTable:
LOAD
date(floor(rand() * $(vNumberOfDates)) + $(vStartDate)) as RandomDate
AutoGenerate 10
;

See attachment.

May you live in interesting times!
MarcoWedel

Hi,

another solution could be:

QlikCommunity_Thread_208333_Pic1.JPG

table1:

LOAD Date(MinDate+Floor(Rand()*(MaxDate-MinDate))) as RandDate

While IterNo()<=10;

LOAD '2016-01-01' as MinDate,

    '2016-03-06' as MaxDate

AutoGenerate 1;

hope this helps

regards

Marco

Not applicable
Author

Very good.

Thaanks

oknotsen
Master III
Master III

If your question is now answered, please flag the Correct Answer (and optionally Helpful Answers).

If not, please make clear what part you still need help with .

May you live in interesting times!