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 09:15:04 +0000
This from Eric Geoffroy - dated 8/12/04 11·37 pm:
> Output should look like this.
>
> 11/1/2004...12/1/2004
Hi, Eric.
Disregard my earlier contributions this thread, which were based on an
incomplete reading of your original post. For the record, here's a revised
(but still resolutely low tech) version of the script I posted earlier. This
one borrows from NG's solution to provide you with the desired result.
--====================================
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 customShortDate(d)
set prevds to customShortDate(prevDate)
set dataset to prevds & "..." & ds
on customShortDate(theDate)
set {year:y, day:d, month:m} to theDate
set m to m as integer
return (m as string) & "/" & d & "/" & y
end customShortDate
--====================================
As with the script I originally posted, this one produces 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.
HTH
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