How to add the last day of the month into a field

How to add the last day of the month into a field
Userlevel 3
Badge +3
  • Zapier Staff
  • 109 replies

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.



6f2cf061cd51a2dcf65adcc670982bb6.png

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:



9918eb8854d8781b1d1bd0333d541dab.png



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:



f1aeed3bf2bf28e5b2e2d65aa4da85a5.png

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:



2de3f50f840b00f98a2244ae95f990c6.png

Et voilà! 


ea46ab4868534fe11b1df5d7e9a2bd07.png



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!


0 replies

Be the first to reply!

Reply