google-apps-script

What happens when you set a Month Timer Trigger to fire on the 31st for a month that doesn't have 31 days?


In a Google Apps Script project, you can set a Time-driven trigger to fire on a monthly basis. For example, on the 31st of every month.

What is the behavior if it is set to a day that does not exist in the current month? For example, will a monthly trigger fire in February if it is set to fire on the 31st? Will it end up firing on the last day of that month?


Solution

  • to be safe I wouldnt count on such undefined behaviour to continue behaving like it happens to behave today.

    If you want to process things at the end of the month better set a daily trigger and first thing in the code check if its the last day of the month. Will consume very little quota to just check once a day.

    Store in script properties the date you last processed to know if you need to run it or not.