LoadRunner function to strip leading zeroes from date

//Use this function to remove the preceding 0’s from the date.
//Displays the date 05/07/2005 as 5/7/2005.

Date_function()
{
char *DayDate, *MonthDate, *YearDate;

lr_save_datetime(“%d”, DATE_NOW, “CurrentDay”);
lr_save_datetime(“%m”, DATE_NOW, “CurrentMonth”);
lr_save_datetime(“%Y”, DATE_NOW, “CurrentYear”);

DayDate= lr_eval_string(“{CurrentDay}”);
MonthDate= lr_eval_string(“{CurrentMonth}”);
YearDate= lr_eval_string(“{CurrentYear}”);

if (strcmp(DayDate,”10″)<0){DayDate = DayDate+1;}
else {DayDate = DayDate;}

if (strcmp(MonthDate,”10″)<0){MonthDate = MonthDate+1;}
else {MonthDate = MonthDate;}

lr_output_message (“Date is %s/%s/%s”, DayDate,MonthDate,YearDate); // Outputs message to the LR log.

}

Author: Richard Bishop

http://about.me/richard_bishop