Hey Zapier Community folks! Sam from Zapier Support Team here.
Have you ever wanted to automatically set a date to be the last day of the month but weren’t quite sure how to do it in Zapier?
Yes? Then read on my friend, because Formatter by Zapier is about to become your best friend!
Ok, so here’s how it’s done. First, we’ll need to add a Formatter (Date / Time > Add/Subtract Time) step and use the {{zap_meta_human_now}} command to add the current date and time as the input.
Next, we add 1 month to that date using the expression +1 month. We’ll want to also set the To Format to be MM/YYYY, like so:
This will give us the next month and current year.
If the app step that we’re putting this date in is able to accept the date in DD/MM/YYYY format then great! We can handle it with that by taking the value from that Formatter step and manually adding in the first day of the month as 01/ and use -1d to subtract one day from it to get the last day of the previous month. For example:
But if it needs the format to be in MM/DD/YYYY then we’ll need to add in an additional Formatter step to subtract 1 day using -1 day and convert the format into MM/DD/YYYY. Like so:
Et voilà!
There you have it, a quick way to get your Zap to automatically output the last day of the current month without needing a more advanced Code step.
I hope you found this useful. Good luck and happy Zapping!