Just looking for a simple script that will give me today’s date minus 90 days, and have that result be a date.
Example: Today is January 16, 2025 so that means that 90 days before today would be October 18, 2024.
Just looking for a simple script that will give me today’s date minus 90 days, and have that result be a date.
Example: Today is January 16, 2025 so that means that 90 days before today would be October 18, 2024.
Hi Homer712.
You’ll love this:
set ninetyDaysAgo to (current date) - 90 * days
The result’s actually 90 * 24 hours before the current date and time. If you’re going to do any serious comparing of dates with the result, you’ll want to set its time to 0, which is equivalent to 12 am (midnight).
set ninetyDaysAgo to (current date) - 90 * days
set ninetyDaysAgo's time to 0
Thank you Nigel, for what I’m doing with the result, the first script is fine.
I was able to modify the script to give me a display on the Desktop (when run as an AppleScript app) using this:
set theDialogText to "Today's date minus 90 days is " & (current date) - 90 * days
display dialog theDialogText
So my question is if there’s a way to eliminate the “time”, as that is not required for what I’m trying to accomplish?
Here it is
set theDialogText to "Today's date minus 90 days is " & date string of ((current date) - 90 * days)
display dialog theDialogText
Thank you, absolutely perfect.
There is also “short date string” if you want it in mm/dd/yy
It actually formats the date according to your locale settings.
For me, it returns yyyy-mm-dd.
For those reading this post, I’m including two screenshots, one of the post 4 script by robertfern, and the second of the short date, also by robertfern. Both work equally well, but for me the longer date seems to work best.