I want to generate a list of dates to pass to a URL for a total of 30 days ending with yesterday’s date in the format YYYY-MM-DD. I don’t know CTL that well so it probably can be done withing a DataGenerator by starting with today - 1 then keep subtracting 1 day until you have a total of 30 days, but I’m not sure of the syntax. Any suggestions would be appreciated!
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,
This was exactly what I was looking for. Thank you for your help!