Iterative GET for each month over last 6 months

Hi Guys ! New here :sweat_smile:

I have a paper company and I have added the Xero module to GET a Xero (accounting tool) Report. The URL includes start and end date of the report. It works fine.
What I’m trying to do now is to get the report for each month for the past 6 months dynamically.

I’ve been struggling here, trying to work with variables and iterators but couldn’t get anywhere.

Can anyone please suggest what’s most efficient ?

Many thanks,
Regards

@Michael_Scott
Hi, I have a feeling that perhaps a function would solve the problem.
For reference, you can use the formatDate,addDays function to output the date 180 days prior to today.

If you want to get the first day of the month or the last day of the month, I think using the setDate function is also effective.
https://www.make.com/en/help/functions/date---time-functions#adddays--date--number-

The usage of the functions and the data that needs to be output would depend on what kind of value you need for the expression “6 months ago”.

Hi @momomomonmon ,

Thanks for the info ! That does get me dates dynamically of last 6 months but what I’m looking for is for my scenario to run for every month over the last 6 months so I can export an updated view of the performance per month.

@Michael_Scott
You can get the first and last day of the month by entering the function as shown in the following image.

Please replace ${number} with the number of months ago, depending on how many months ago you want to get the value.

//1st
{{formatDate(setDate(addMonths(now; ${number}; 1); "YYYY-MM-DD")}}

//end of month
{{formatDate(setDate(setDate(addMonths(now; ${number}); 32); -1); "YYYY-MM-DD")}}


//sample
{{formatDate(setDate(addMonths(now; -1); 1); "YYYY-MM-DD")}} //output: 2025-01-01
{{formatDate(setDate(setDate(addMonths(now; -2); 32); -1); "YYYY-MM-DD")}} //output: 2024-12-30

Welcome to the Make community!

You should simply use a repeater module, and an aggregator at the end to combine the 6 cycles into a single bundle.

Hope this helps! Let me know if there are any further questions or issues.

@samliew

P.S.: Investing some effort into the Make Academy will save you lots of time and frustration using Make.

2 Likes

Thank you ! Managed to make it work with both of your suggestions !
Regards

Hey there @Michael_Scott :wave:

Glad to hear you were able to resolve your issue with the help of @samliew and @momomomonmon!

Would you mind marking one of the suggestions as a solution so we keep our community healthy and organized? :pray:

Thanks and have a wonderful day! :sunny:

2 Likes