Re: Subtract 1 month from date
Re: Subtract 1 month from date
- Subject: Re: Subtract 1 month from date
- From: Mr Tea <email@hidden>
- Date: Thu, 09 Dec 2004 01:21:36 +0000
This from Eric Geoffroy - dated 8/12/04 11·37 pm:
> it won't allow "d + 1 * months
That's because months contain a variable number of days.
Here's a little something that will get you dates that are 'numerically' a
month apart (ie the same day of each calendar month). In cases where the day
number of the current month is greater than the total number of days in the
previous month, the last day of the previous month is returned.
--===================================
set d to (current date)
set x to 28
set theDay to day of d
repeat
set prevDate to d - (x * days)
set prevday to day of prevDate
if (month of d) = (month of prevDate) then
set x to x + 1
else
if prevday ¾ theDay then
exit repeat
else
set x to x + 1
end if
end if
end repeat
set ds to short date string of d
set prevds to short date string of prevDate
set dataset to prevds & "..." & ds
dataset -->"09/11/04...09/12/04"
--===================================
Note that the short dates are generated in this format (DD/MM/YY) without
the need for further editing because I have set them thus in the date format
section of the international prefs panel.
And btw, we don't like malapropisms here. This is a local list for local
people.
Nick
pp Mr Tea
--
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Applescript-users mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden