Customer Portal

Generating Dates for the Last 30 Days

Comments 2

  • Avatar
    krizovav
    0
    Comment actions Permalink
    Hi,

    If you would like to receive a list of dates in one record, it has to be set in metadata at first. Set the Type to “date”, Container type to “list” and Format to “yyyy-MM-dd”, please. Then you can use the code below in DataGenerator.

    function integer generate() {	

    date[] list1;

    for(integer i = 1; i <= 30; ++i) {
    list1 = push(list1, dateAdd(today(), -i, day));
    }

    $out.0.field1 = list1;

    return ALL;
    }


    If you prefer a single record for each date (30 records), put the Normalizer after the DataGenerator and use the code below in it. It will convert multivalue field to multiple records.

    function integer count() {

    return length($in.0.field1);
    }


    function integer transform(integer idx) {

    $out.0.field1 = $in.0.field1[idx];
    return OK;
    }


    I hope this helps.

    Regards,
  • Avatar
    kmac21
    0
    Comment actions Permalink
    This was exactly what I was looking for. Thank you for your help!

Please sign in to leave a comment.