LoadRunner function – Add Five Minutes to the current time and save as a string

I needed to write a function which adds five minutes to the current time so that I could create appointment start and end times for an application used in bank branches to make appointments for customers. The function that I’ve written could be modified to add more or less time, the clever bit is making sure that it handles the last few minutes of an hour properly.

For example.
13:56 + 5 minutes = 14:01

The function handles this by converting the 13 and the 56 into integers, doing the necessary sums and then converting the results back into strings which LoadRunner can use.

When the integers are converted back to strings, single digit number are displayed correctly e.g. 01,02,03 etc. rather than 1,2,3.
The function will not work in the last five minutes of the day because I haven’t added a function to add five minutes to 23:56 to get 00:01. (If you’re running tests this late, don’t use this function).

The sample script can be downloaded from my discussion forum.
AddFiveMinutes.zip

Author: Richard Bishop

http://about.me/richard_bishop