HomeSUPPORT QUESTIONS

Need help with StresStimulus? Start here.

Returning the age of a random birthdate Messages in this topic - RSS

Unregistered User
Unregistered User
Posts: 509


12/11/2021
Unregistered User
Unregistered User
Posts: 509
How can I create a random birthdate and then return the age?
0 link
George @StresStimulus
George @StresStimulus
Administrator
Posts: 554


12/11/2021
George @StresStimulus
George @StresStimulus
Administrator
Posts: 554
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 © 2024 Stimulus Technology