I am working on a script which has 2 fields - Doc Validity Start date and End Date. For testing purpose, we have decided to keep the validity as 4 days. While recording the script, the start and the end date is coming in Unix format (with milliseconds). I am aware of the function lr_save_timestamp to capture the current date, which can be used for From Date. However, i am not able to perform the offset of time period by 4 days. I tried converting the captured time stamp to INT and performing mathematical operations, but the time stamp is so huge that even double could not help me on this and as a result i am not able to add the offset value. All the data types - int, long, double were getting exhausted.
Can someone help me on how to make this work?
for example, captured timestamp - 1686700800000
offset value in milliseconds - 345600000
Final value (which will serve as End Validity date) - 16870473000000
I am trying to embed the following code in the Load Runner script which we are developing using C Language
timestamp()
{
long long int test;
double fromDate , toDate ;
lr_save_timestamp("time",LAST);
lr_output_message("Now -> %s", lr_eval_string("{time}"));
fromDate = atoi(lr_eval_string("{time}"));
test = atoi(lr_eval_string("{time}"));
lr_output_message("Now -> %ld", fromDate);
lr_output_message("Now -> %.0f", fromDate);
lr_output_message("New -> %d",test);
return 0;
}
Following is the output
Starting iteration 1.
Starting action timestamp.
timestamp.c(7): Notify: Saving Parameter "time = 1686784563045".
timestamp.c(9): Notify: Parameter Substitution: parameter "time" = "1686784563045"
timestamp.c(9): Now -> 1686784563045
timestamp.c(11): Notify: Parameter Substitution: parameter "time" = "1686784563045"
timestamp.c(13): Notify: Parameter Substitution: parameter "time" = "1686784563045"
timestamp.c(15): Now -> -4194304
timestamp.c(17): Now -> 2147483647
timestamp.c(19): New -> 2147483647
Ending action timestamp.
Ending iteration 1.
Since the value thats coming in variable "time" and value in "fromDate" or "test" is different, i am not able to perform the addition operation.
The following has been tested in LoadRunner and produced the output you desire. Adjust accordingly for two days or four days. Three days of offset used for the example
And, the output