Forum Discussion

rpc1235x's avatar
rpc1235x
New Contributor II
2 years ago
Solved

Dynamic range of dates for REST

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

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. 

#RestGet #Dates 

  • 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.

    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!

3 Replies

  • 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.

    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!

    • rpc1235x's avatar
      rpc1235x
      New Contributor II

      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 - Based on the error, I think you just need to add the expression library reference in your pipeline properties.