cancel
Showing results forย 
Search instead forย 
Did you mean:ย 

Dynamic range of dates for REST

rpc1235x
New Contributor

My current pipeline works with pipeline parameters defining the range of dates

rpc1235x_0-1695413731305.png

However my goal is to automatize this for each month. My idea is to schedule a task for the first of every month and I would like to dynamically set date2 as Today minus one day in yyyy-mm-dd format (no time) and date 1 as Today minus one month. So that if Today is October first, then date 2 is 2023-09-30 and date 1 is 2023-09-01.

To accomplish this, I am trying to utilize the query parameters section in the REST Get snap. However, I am not able to properly create the functions. As I am not familiar with the snap functions and the documentation is not very explicit on how to combine multiple functions. I would appreciate any help. 

rpc1235x_1-1695413943268.png

#RestGet #Dates 

1 ACCEPTED SOLUTION

koryknick
Employee
Employee

@rpc1235x - I created an set of expression libraries a while back that I think will resolve this for you.  Rather than try to calculate this in a pipeline parameter which really only allows for static strings, I suggest you use the date.expr expression library and calculate the start and end dates in a Mapper snap as in the following screenshot.

koryknick_0-1695559693726.png

You could choose to not use the expression library reference and perform the date truncation in the Mapper itself, but the "trunc" method simplifies the statement in your Mapper (and I like simple).  ๐Ÿ˜‰

I hope this helps!

View solution in original post

3 REPLIES 3

koryknick
Employee
Employee

@rpc1235x - I created an set of expression libraries a while back that I think will resolve this for you.  Rather than try to calculate this in a pipeline parameter which really only allows for static strings, I suggest you use the date.expr expression library and calculate the start and end dates in a Mapper snap as in the following screenshot.

koryknick_0-1695559693726.png

You could choose to not use the expression library reference and perform the date truncation in the Mapper itself, but the "trunc" method simplifies the statement in your Mapper (and I like simple).  ๐Ÿ˜‰

I hope this helps!

Thank you for the response. 

I have imported the expression library files to the Project Manager section. However, I have this error in the mapper connected to the REST Get. Is there an additional step to enable the expression library?

rpc1235x_0-1695670968655.png

rpc1235x_1-1695671036235.png

 

 

koryknick
Employee
Employee

@rpc1235x - Based on the error, I think you just need to add the expression library reference in your pipeline properties.

koryknick_0-1695837573244.png