Test Data Manager

  • 1.  Is it possible to increment a datetime column using the STIMESTAMP variable

    Posted Dec 14, 2016 05:18 PM

    Hello,

     

    Is there is a way to increment the system timestamp variable based on the number of table repeat count I put in?  For example, I have a FileDate column that is a datetime field, and I would like the date to increment by 1 day for each table repeat count used. I looked through the Functions and Parameters page to find a function for this purpose but am not able to figure out which one would work since the field does not accept any function that is not date time.  The STIMESTAMP is perfect variable for this column however, I would like for that data to increment instead of staying static.

     

    Here’s the sample data I’d like to generate if I use a table repeat count of 3:

     

    Table A

    LoadNum            FileDate

    1234                       2016-12-13 00:00:00.000

    3456                       2016-12-14 00:00:00.000

    5678                       2016-12-15 00:00:00.000

     

    Thank you,

    Tam



  • 2.  Re: Is it possible to increment a datetime column using the STIMESTAMP variable
    Best Answer

    Posted Dec 15, 2016 09:12 AM

    There is more than one approach to solve for this.  Only thinking out loud but, there is a Utility Filter that will generate a date and allow you to provide an offset, but your requirement implies that you have a variable number of dates to calculate.  

    You might consider a implementing some script (JSR-223 step, Scripted Assertion, etc.) within a loop that calculates the value of a date.  For example:

    <add imports>

    // your date could be preset for the first time through using the date filter found in Utilities

    // assume that the date filter creates a current date in proper format and stores this date

    // in a property called 'prop_date'

    String aDt = testExec.getStateValue( "prop_date" ); 

    // set up a date format and create a calendar using the date then add one day to the date
    SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd' 'HH:mm:ss.SSS");
    Calendar cal = Calendar.getInstance();
    cal.setTime( sfr.parse(aDt) );
    cal.add( Calendar.DATE, 1 );

    // ADD code here to do something with the date or allow another step

    // in the process to do something with the date before generating the

    // next date

    aDt = sdf.format( cal.getTime() );

    // do something

    //   :

    // set the date value back so next loop increments 1 day from previous loops date value
    testExec.setStateValue( "prop_date", sdf.format( cal.getTime() ));

    // if JSR-Step return and print the date as the last response

    return sdf.format( cal.getTime() );

    // OR if Assertion, change the Assertion to error when response is FALSE

    return true; 



  • 3.  Re: Is it possible to increment a datetime column using the STIMESTAMP variable

    Posted Dec 19, 2016 05:41 PM

    Thanks for the feedback Joel.  Is the Utility Filter and or the scripts you've described included in DataMaker tool?  That is the tool I am using to generate synthetic load records to simulate loading files into the database for different days using the functions and variables provided within the tool.  Unfortunately I am also new with DataMaker so I don't know all the usage of the tool yet and trying to understand what each function means.

     

    Thanks,

    Tam