Forum Discussion
Hello @skodali
I tested a bit with your issue and come up with some solution. Please check this pipeline and the csv test file, and see if that can help you.
test2_2020_06_12.slp (8.8 KB)
and csv file structured like screenshot bellow
BR
Dimche Saveski
- tstack7 years agoFormer Employee
You can use the Sequence snap at the head of the pipeline to generate a series of documents with an index number that you can then transform with a Mapper to get a series of dates.
If you can’t make the Sequence snap the head of the pipeline, you can use the
sl.range()
function to generate an array and then use theArray.map()
method to transform the dates.sl.range(_days).map(x => Date.now().minusDays(x).toLocaleDateString({ format: "MM-dd-yyyy" }))
To break this down:
-
sl.range(_days)
- The_days
pipeline parameter contains the number of days to go back. Thesl.range(...)
call then produces an array that looks like[0, 1, 2, 3]
. -
.map(x => ...)
- Each element in the array will be transformed by the given callback function. -
Date.now().minusDays(x).toLocaleDateString({ format: "MM-dd-yyyy" })
- This will get the current date-time, subtract one day and then turn the result into a string.
I’m attaching a pipeline that demonstrates both methods:
DateArray_2018_10_17.slp (6.9 KB)
- arvindnsn7 years agoContributor
This is Brilliant having multiple solutions. Thanks so much for teaching to use the map method.
-