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 ?
Solved! Go to Solution.
yes
Hi @tjamal1,
An interesting one.
I broke it down into the following formulas:
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.
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
Can you add days ,hours , and minutes to our first column
can I add random "hours" in second column
e.g First column + Random(Hours)
where Hours = 24 - 96
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