DAY TIME CALCULATION: LAST DAY OF PREVIOUS MONTH

Discussion, questions and support.
Post Reply
Mr.Aky
Posts: 33
Joined: May 21st, ’19, 06:49

Post by Mr.Aky » Jun 9th, ’25, 07:01

Hello,
How can I send last day of previous month in a Shortcut ?

In date and time I do not find a way to send last day of previous month.
I can send first day of previous month with this formatting 01/MM/yyyy
User avatar
Marko
Posts: 1874
Joined: Mar 2nd, ’13, 21:02

Post by Marko » Jun 9th, ’25, 20:19

Code: Select all

TDate := A_YYYY A_MM "01" ; Start Date of Current Month
TDate += -1, D            ; End Date of Previous Month 
FormatTime, fileDate, %TDate%, dd.MM.yyyy
Send, %fileDate%
Mr.Aky
Posts: 33
Joined: May 21st, ’19, 06:49

Post by Mr.Aky » Jun 11th, ’25, 05:46

Thanks,
it works
piper977
Posts: 1
Joined: Jun 28th, ’25, 11:41

Post by piper977 » Jun 28th, ’25, 11:49

To get the last day of the previous month in Shortcuts, try this simple approach:

Get Current Date

Adjust Date

Subtract the number of days equal to the current day (Get Day of Date, then Adjust Date by -[that number] days). This brings you to the last day of the previous month.

Format Date

Format it as dd/MM/yyyy to send.

I used a similar date trick earlier while doing my [SASSA Status Check][/https://srd-sassa-gov.co.za/] – Shortcuts really makes quick calculations like this easy.
Post Reply