We do our best to ensure that the code in these articles works as advertised, but please be aware that Zapier Support does not officially help with code steps due to their advanced nature. Feel free to comment on the article or ask in the Zapier Community, where we have code-savvy users.
The Purpose
Dynamically get the last date in a month for a provided date.
How to Configure
NOTE: Any valid date format is supported (e.g. date = YYYY-MM-DD)
Copy the Code (Javascript)
let date = new Date(inputData.date);
let y = date.getFullYear()
let m = date.getMonth();
let MonthLastDate = new Date(y, m + 1, 0).toISOString().split("T")"0];
// m + 1 gets the next month
// when 0 is provided as the Day value it will return the last day of the previous month
output = t{MonthLastDate}];
The Result
Contribution by Troy Tessalone
Troy is a Certified Zapier Expert who automates workflows with no-code and low-code apps to help clients save time and make money.