Re: Subtract 1 month from date
Re: Subtract 1 month from date
- Subject: Re: Subtract 1 month from date
- From: Nigel Garvey <email@hidden>
- Date: Thu, 9 Dec 2004 01:55:52 +0000
Eric Geoffroy wrote on Wed, 08 Dec 2004 15:37:21 -0800:
>
>Or 4 weeks I suppose. It's okay if it's not super precise.
>
>I can say "d + 4 * weeks"
>but it won't allow "d + 1 * months
>and won't allow d - 1 * weeks
>
>Output should look like this.
>
>11/1/2004...12/1/2004
on addCalendarMonths(theDate, m) -- m negative for subtractions
copy theDate to newDate
set {y, m} to {m div 12, m mod 12}
if m < 0 then set {y, m} to {y - 1, m + 12}
set newDate's year to (newDate's year) + y
if m is not 0 then tell newDate to set {day, day} to {32 * m, day}
if newDate's day is not theDate's day then set newDate to newDate -
(newDate's day) * days
return newDate
end addCalendarMonths
on USshortDate(theDate) -- no leading zeros/US format
set {year:y, day:d} to theDate
copy theDate to b
set b's month to January
set m to (b - 2500000 - theDate) div -2500000
return (m as string) & "/" & d & "/" & y
end USshortDate
set endDate to (current date)
set endDate's day to 1
set startDate to addCalendarMonths(endDate, -1)
set searchrange to USshortDate(startDate) & "..." & USshortDate(endDate)
NG
_______________________________________________
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