Home Forums Programming Testing Generating dynamic dates from stored parameters/criteria RE: Generating dynamic dates from stored parameters/criteria

  • D. Clark (6/19/2014)


    Hello all,

    Not sure if this is the best forum for this but since it is in the realm of testing I thought I would try here first. I am in the process of creating a script to test out certain aspects of a stored procedure. The stored procedure relies on various tables to return a result set. This means that I need to populate these tables with data for testing. I've already ruled out using a copy of production data since it may not be reliable (as the stored procedure might not be too reliable in the first place...garbage in garbage out).

    Instead, I am creating record templates (stored in their own tables) that the testing script calls to populate the application database with dummy records for testing. My biggest problem has been date creation. I can't hard code since a date that might make sense now won't make sense 2 or 3 years (maybe even months) from now, and I want to populate these "templates" once. That way testing is a matter of just executing the script and comparing the results to expected results.

    The question I am getting stumped on is what is the best way to store the parameters to generate the dates. The worst case is that I can have fields to store the years, months, and days. It can also store whether or not the date should occur at the beginning, 15th, end of the month that the calculation landed on. It could also use the day for the current day but the 29th through the 31st might cause some issues obviously. However that means adding a large number of fields for each date field.

    I am thinking I can get away with just month and a day indicator (e.g. first, tenth, fifteenth, twentieth, last, or current day). I just can't get the feeling that I am reinventing the wheel and that there is something out there that can do all of this. However, googling dynamic dates, dates criteria, and etc doesn't shed too much on this subject?

    Anyway I would be interested in any suggestions/opinions.

    I don't know exactly what you're going for but the following article may provide some food for thought in the area of generating test data, specifically where dates are concerned.

    http://www.sqlservercentral.com/articles/Test+Data/88964/

    --Jeff Moden


    RBAR is pronounced "ree-bar" and is a "Modenism" for Row-By-Agonizing-Row.
    First step towards the paradigm shift of writing Set Based code:
    ________Stop thinking about what you want to do to a ROW... think, instead, of what you want to do to a COLUMN.

    Change is inevitable... Change for the better is not.


    Helpful Links:
    How to post code problems
    How to Post Performance Problems
    Create a Tally Function (fnTally)