Back to Blog
Back to Blog
Vugen: Manipulate The Date
Posted on Aug, 2012 by Admin
When using the lr_save_datetime function, you may want to advance or decrement more than one day, you have to multiply by the number of days.
Example code:
// Display Current Date Only
lr_save_datetime("%m/%d/%Y",DATE_NOW,"Currdate");
lr_output_message("Current Date: %s",lr_eval_string("{Currdate}"));
// Subtract 30 days from current date
lr_save_datetime("%m/%d/%Y", DATE_NOW - (ONE_DAY*30), "Startdate");
lr_output_message("Previous 30 Days: %s",lr_eval_string("{Startdate}"));
// Advance 30 days from current date
lr_save_datetime("%m/%d/%Y", DATE_NOW + (ONE_DAY*30), "Startdate1");
lr_output_message("Advance 30 Days: %s",lr_eval_string("{Startdate1}"));
As of LoadRunner version 7.8 and higher, there is an offset function in the date/time parameter properties box that let’s you set the date back or forwards by as many hours/minutes/seconds as you want.