Alteryx Designer Desktop Discussions

Find answers, ask questions, and share expertise about Alteryx Designer Desktop and Intelligence Suite.
SOLVED

Generate Random Random Date and Time

tjamal1
8 - Asteroid

I want to generate Random Date and Time in two columns 

 

First column contain -> Random date and time 

StartDate: 01/02/2019
EndDate: 30/11/2019

Time : any hour:mm:ss  of the day 

Expected output format : dd-mm-yyyy hh:mm:ss 

 

2nd column : First column + (Random Hours + Random Minutes)

 

Is there anyway to do it in Alteryx ?

9 REPLIES 9
afv2688
16 - Nebula
16 - Nebula

Hello @tjamal1 ,

 

The random date has to be  between the start date and the end date?

 

Regards

tjamal1
8 - Asteroid

yes

JoeS
Alteryx
Alteryx

Hi @tjamal1,

 

An interesting one.

 

I broke it down into the following formulas:

2020-01-03_12-09-13.png

 

The first formula is the key part, its a random number between 0 and the total number of seconds in a year.

 

Hopefully they make sense after that with what I was doing, and I left them broken down like that to hopefully help.

 

You could roll them up to be just two formulas if need be.

RolandSchubert
16 - Nebula
16 - Nebula

Hi @tjamal1 ,

 

I assume, you want to create one row and the limit for hours in column 2 is 24 and for minutes 60. The first step is to convert the start / end dates to a datetimeformat. Then you can calculate the difference in seconds between the dates, use RandInt to create a random number between 0 and the difference and DateTimeAdd to add this number to the start date. Second column can be calculate use a similar method. I've attached a sample workflow.

Does this help?

 

Best,

 

Roland

afv2688
16 - Nebula
16 - Nebula

Hello @tjamal1 ,

 

Here you go

 

Cheers

tjamal1
8 - Asteroid

Can you add days ,hours , and minutes to our first column

JoeS
Alteryx
Alteryx

Hi @tjamal1 

 

Sorry I misread it first time round.

 

I have redone it here:

2020-01-03_13-55-17.png

tjamal1
8 - Asteroid

can I add random "hours" in second column 

 

e.g First column + Random(Hours) 

where Hours = 24 - 96 

 

 

JoeS
Alteryx
Alteryx

You can change it round to be hours rather than seconds.

 

You'll want to check there are enough hours left to add on 24-96, then you can do RandInt(72)+24

Labels