I have the month and year and wanted to get the last day to set dynamically for my parameters thought this might help someone else
if checks if adding one day to the 30th results in the same month. If it does, the month has 31 days. If not, it has 30 days.
if checks if adding one day to the 29th keeps it in the same month. If it does, it continues to the innermost
if. If not, it directly returns 29.
if starts with the 28th, and if adding one day keeps it in the same month, it proceeds to the middle
if. If not, it directly returns 28.
It’s interesting seeing all the workarounds we have to come up with when we need something there isn’t a straightforward method to get it.
Here’s also another way to approach this:
Given the month and year, string together a date for the first day of that month and use parseDate() on that.
For this month, 10, and this year, 2023, we get 10-1-2023.
Then, add a month, so 11-1-2023.
Then, remove 1 day, so 10-31-2023.
Use a formatDate if you just need to get the day number.
so many ways to get to the same answer with different methods.
@Mr.Make thanks so much for hopping into the community and sharing this ‘cheat sheet’ with us. Super valuable stuff.
The same goes for
@Donald_Mitchell , of course. Thanks for letting us know how you go about working with the last day of month in Make.
Oh and this is so true! It’s really interesting to see how different folks choose different approaches to certain concepts in Make
On a similar note, there’s also this community post about scheduling your scenarios to run on the last day of the month.
Ever wondered how to set up your scenarios so that they run on the very last day of the month?
Check out this step-by-step guide on how to do exactly that
The setup consists of 2 parts:
scheduled runs on 28,29,30 and 31 of each month
a filter that checks if it is actually the last day of the given month
Set the schedule to 28,29,30 and 31 of every month.
2. Filter with functions after tri…