Change API call based on date range divided into 15 day chunks

I’m trying to modify an API call so that it only pulls data down in 15-day increments (because otherwise the dataset is too large and I get an error).

I’ve created a component that asks for the start and end date, and then I can calculate the number of 15 day periods that I need, but I’m struggling to figure out how to make a loop that will take the start and end dates for each of the 15 day periods. My first thought is that I should create a nice data table with start and end dates for each period.

For example, if a user puts in a start date of April 1 and an end date of May 31, It should be split into 5 chunks.

image

Then, after splitting it into these 5 chunks, I’d like to use a loop so that it can replace the start and end date in the API call using a string manipulator and make 5 separate calls for each of the 5 date chunks.

Any ideas on how to do this?

I guess there are probably 10 or 100s of ways of doing it. My first thought was the “Create Date&Time Range” node which can take a flow variable (eg user input) for start and end date with interval 1d. This will generate all days in the time period. Then you use the chunk loop start node and set chunk size to 15. And in the loop you use group by to get min and max (eg start/end) for the current chunk and then use that to make you API call.

image

3 Likes

Awesome, I’m just testing this, and I think it will work perfectly. Thanks!

Hi there @stevelp,

probably Window Loop Start node should be able to help as well.

Br,
Ivan

2 Likes

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.