Imagine that your test logic requires you to get a random date-of-birth aged between 20 and 80 years. Here is how you can go about it.
ACCELQ supports a date command to get a random past date between two given numbers of days. For example, the following statement returns a random date in the past, between 30 to 90 days.
Command Name: "Get random date time"
Get a random date between '30' to '90' days in the past (format: MM/dd/yyyy). Store result in random date
In our date-of-birth question, we need to first arrive at the min and max days based on the 20 and 80 years. And then using these days, we will find the random date.
In the example below, we use expression builder to calculate the number of days in 20 years and 80 years.
Note: You can insert additional logic in case you need to convert the date format. Here is how.
Comments
0 comments
Please sign in to leave a comment.