Systems & Software Talk 

Visitors since August 14, 2007: Free  Web Counters
Free Hit Counters

LoadRunner - Correlated Date Comparison

04:56, 2007-Aug-12  ..  Posted in LoadRunner Tips and Tricks  ..  0 comments  ..  Link

= ** Date Comparison Utility ** =

If you arrived here looking for tips on how to compare (depending upon your orientation) your dates with "Gloria" or "Betsy" or with "Duke" or "Beaufort", you came to the wrong place. While you might be interested in dating parameters, this topic has a different context. We are not dealing with parameters such as "First Date Suck Face Scale" or "Dinner Tight-Wadness" or "Opened Car-door For Me But Slammed It And Crushed My Roses" or "Flirt level With Waiter Or Waitress" or "Alcoholic Beverage Guzzle Rate" or "Frequency Of Change Topic To All About Me". We are dealing in ones and zeros here. Sure your date may have been a zero but really, we are talking two different types of parameters. Still not convinced that this is not about humans and dating? I know you are thinking about the word "LoadRunner". Sure your date turned out to be an extreme emotional Load and during dinner you daydreamt that you were a first class Runner. But honestly, this is about information technology. Anyway...

This is derived from a bucket of code that is also shared at SQAForums: www.sqaforums.com. I wrote a piece and then ptrussell_nc discovered a flaw in the original and fixed it. Too bad it isn't that easy to fix a flaw in a date - heh?

The purpose of this code fragment is as follows:
In general within this example, compare two dates of the format "mm/dd/YYYY" and then output the result in the "if" block. You would adapt this to your specific needs. It is best to keep the local script host system date capture in the Action section in the event you run a test thats spans more than one day.
Capture today's date from the script host system date

  1. Save it into an LR parameter
  2. Capture the desired date for a specific item from the server
  3. Compare the Years to see if they are different. If they are, this determines which date is before which.
  4. Compare the full dates if the Years happen to be the same.

* Results from 4 & 5 above can be: 1) date is before, 2) date is after, or  3) the date is the same.


If you wish to compare dates of different formats, then you would adjust the formatting codes appropriately. The code may also need to be modified.

Note from ptr: In merging this code this rewritten it to be slightly more efficient and compact.
/* Authors:  JakeBrake & ptrussell_nc of SQAForums.com
   Version:  1.1
   Date:  1-Aug-2007 */
{
int rc;
int refrel;
char *today;
char *refDate;

/*  lr_eval_param is going to return a block of memory that
we can use. We don't need to write those results to a temporary buffer. This next line saves today as mm/dd/yyyy in "dateToday" */

    lr_save_datetime("%m/%d/%Y", DATE_NOW, "dateToday");
    /
* Below goes before the LR request that would capture the date */
    web_reg_save_param("CapturedDate", "LB=The left bound", "RB=The right bound", LAST);
    /* Save LR parms in two different "C" strings, then compare the two */
    today = lr_eval_string("{dateToday}");
    refDate = lr_eval_string("{CapturedDate}");
    lr_message("today %s  capturedate %s",  today, refDate);  // for debugging
    refrel = 0;  

    /*  -1 for before today, 1 for after today compare the years first */
    refrel = strcmp(refDate + 6, today + 6);
    /* if the years are the same (refrel = 0)  then compare the full dates */
    if (!refrel)  refrel = strcmp(refDate, today);
    /* Note well the text of the lr_message! */
    if (refrel < 0)  
            lr_message("refDate is before today ");
    else if (refrel > 0)  
            lr_message("refDate is after today ");
    else lr_message("refDate is today ");
    return 0;
}

Do you still think this is about the human dating experience? Are his or her parameters important to you? Do you wish to have a good correlating experience? Please let me refer you to here.

Oh arighty then.. you came here for dating pointers. Here are some! It's all in the fingernails:

  1. If you bust him during a tabletop sleight-of-hand magic trick such that you see him tuck/pull the vanished/reappeared silver dollar to/from under a fingernail; he might not be right for you.
  2. If she is a tabletop fingertip tapper and after a couple rhythmical percussive pieces she leaves a heap of wood chips, you should leave the restaurant alone. Take the wood chips with you for fireplace kindling.

 


 

{ Last Page }   { Page 12 of 46 }   { Next Page }

About Me

Home
My Profile
Archives
Friends
My Photo Album

Links

Corey Goldberg
Effective Testing?
Bj Rollison I.M. Testy Blog
Alan Page: Software Testing & Rants
Dmitry's LoadRunner and QTP Blog
Veterans History Project
Air Traffic Control Watch
Music Making Fun
My home 1972-1975

Categories

Functional Testing
Performance Horror
Development
Performance Testing
General
Tools Tips
Warped Humor
LoadRunner Tips and Tricks

Recent Entries

New Year’s Eve of 2010 Catastrophe In the Works
Introducing Testalis
Defect Report - Politically Correct
Performance Testing Vuser Personas – Part I
Happy Holidays 2007

Friends

LauraScharp
philk10
richardw100
aalhait
jimhazen
strazzerj
Lynnem
bru
EklecticTester
jgottlieb
leakybrain
michaeljf
prainbow
rajeshmathur
rstens
Yury
zeeslo
whollymindless

Syndication

RSS Site Feed