Need help with StresStimulus? Start here.
Returning the age of a random birthdate
Unregistered User Posts: 475
12/11/2021
|
How can I create a random birthdate and then return the age?
|
|
0
link
|
George @StresStimulus Administrator Posts: 511
12/11/2021
|
First, create a Date data generator called “MyDOB” that returns a date between today and 100 years ago as follows:

Then, create a scriptable called “GetDOBYear” variable that will read the MyDOB and return number of years”. string IExternalVariable.GetValue(SessionContext context) { var sDOB = context.GetDatageneratorValue("MyDOB"); var dob = DateTime.Parse( sDOB); var years = new DateTime(DateTime.Now.Subtract(dob).Ticks).Year; return years.ToString(); }
|
|
0
link
|
Copyright © 2023 Stimulus Technology