1. SPEForums need your contributions to build up a strong repository of performance engineering resources.

    Dismiss Notice
Dismiss Notice
Hello Guest,

Please reach out to us at anmldubey@gmail.com in case you face any issues with SPEForums. Share your feedback - Click Here

Please support us by sharing performance engineering tutorials/resources with SPEForums.com


Loadrunner Function to write current system Time 2017-12-05

A basic example script to print current time stamp

  1. admin
    This main use of this functions to return the current system time at any given point of time while loadrunner script is running.This function can be used to report transaction times , script starting time and end time.

    Attached is a sample script for demo purpose.

    Please share more methods to work with date time functions on loadrunner and support this community.

        lr_save_datetime("Today is %H %M %S", DATE_NOW, "curr_time");
        return 0;
    long get_secs_since_midnight(void)
    char * curr_hr; /* pointer to a parameter with current clock hr */
    char * curr_min; /* pointer to a parameter with current clock min*/
    char * curr_sec; /* pointer to a parameter with current clock sec */
    long current_time, /* current number of seconds since midnight */
    hr_secs, /* current hour converted to secs */
    min_secs, /* current minutes converted to secs */
    secs_secs; /* current number of seconds*/
    curr_hr = lr_eval_string("{current_hr}>");
    curr_min = lr_eval_string("{current_min}");
    curr_sec = lr_eval_string("{current_sec}");
    hr_secs = (atoi(curr_hr)) * 60 * 60;
    min_secs = (atoi(curr_min)) * 60;
    secs_secs = atoi(curr_sec);
    current_time = hr_secs + min_secs + secs_secs;
    Output of above code:


    Other Example: lr_save_datetime

    In the following example, lr_save_datetime retrieves tomorrow's date.

    lr_save_datetime("Tomorrow is %B %d %Y", DATE_NOW + ONE_DAY, "next");
    // Output: Action.c(4): Tomorrow is November 18 2014

    These examples show the effect of formatting:

    lr_save_datetime("%Y-%m-%d", DATE_NOW, "dateReceived");
    // Output: Action.c(7): 2014-11-17

    lr_save_datetime("%m/%d/%Y %H:%M", DATE_NOW, "currDateTime");
    // Output: Action.c(10): 11/17/2014 15:14