Qlik Community

QlikView Scripting

Discussion Board for collaboration on QlikView Scripting.

Not applicable

AutoGenerate

Hi

How generate 10 Random Date between 2 Dates

4 Replies
oknotsen
Honored Contributor III

Re: AutoGenerate

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!

Re: AutoGenerate

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

Re: AutoGenerate

Very good.

Thaanks

oknotsen
Honored Contributor III

Re: AutoGenerate

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!
Community Browser