-
Notifications
You must be signed in to change notification settings - Fork 58
Script: LastMonth
Samuel Plentz edited this page Sep 16, 2023
·
1 revision
This script gets the name of the previous calendar month.
It is a special case of the community script DateOffset that does the same with:
[[SCRIPT=DateOffset|0|-1|monthname]]
const months = ["December", "January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November"];
var date = new Date();
return months[date.getMonth()];
Here's one example, in the event you are self-employed and bill your clients monthly:
Please find an invoice for [[SCRIPT=LastMonth]] attached.
would resolve to:
Please find an invoice for February attached.
I also have a French variant of this script which essentially replaces "December" with "décembre" and so on, and a "French possessive" variant which instead uses "de décembre" (in order to account for contractions in months that begin with a vowel, e.g. "d'avril").