My goal is to generate random dates that are older then 65 years from time of run. I was using the Datetime function but I’m getting an unexpected error.
Here is my code

Here is my error

here is my little workflow
DOB_genator.zip (2.2 KB)
My goal is to generate random dates that are older then 65 years from time of run. I was using the Datetime function but I’m getting an unexpected error.
Here is my code

Here is my error

here is my little workflow
DOB_genator.zip (2.2 KB)
Hello
How about replacing 365 * 65 with 23725
Next(0,23725)
Or
Can you try breaking down the steps into multiple assigns.
Start with the 365 * 65 step first as the error mentions ‘Next’
Hopefully this helps
Cheers
Steve
@Steven_McKeering Thanks, I tried breaking it down, but still getting that error on Next. From the docs I have read, it should work just fine. I must be missing something
Hello
Try this:

Assign 1

Assign 2

Result
![]()
Hopefully this helps,
Cheers
Steve
Back again
Yep you can achieve in one assign.
Try the syntax like this,

![]()
Cheers
Steve
@Steven_McKeering Thanks the single syntax using a new Random object fixed the compile error.
However, my output, the date ( which should be DOB older than 65 years old) is not accurate. its returning dates that are not older than 65 years old.
RHS of Assign
full assign

inaccurate outputs
![]()
![]()
![]()
Missed a minus…
Try this:
DateTime.Today.AddYears(-65).AddDays(-(new Random().Next(1,23725))).ToString(“yyyy-MM-dd”)

![]()
Try this:
DateTime.Today.AddYears(-65).AddDays(-New Random().Next(0, 365 * 65)).ToString("yyyy-MM-dd")
Regards
@vrdabberu and @Steven_McKeering Both variations worked! I can only mark one as the solution. but THANK YOU BOTH very much.
This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.