• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: Need help with finding first of the month
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Need help with finding first of the month


  • Subject: Re: Need help with finding first of the month
  • From: Walter Ian Kaye <email@hidden>
  • Date: Thu, 1 Jul 2004 15:27:23 -0700

At 02:00p -0700 07/01/2004, Paul Berkowitz didst inscribe upon an electronic papyrus:

On 7/1/04 1:00 PM, "Young, Rich A." <email@hidden> wrote:

> I need to add a piece to an existing script that will find how many days it
> is until the first day of the next month from any given date taking into
> account things like leap year. Can anyone point me in the right direction

I'm going to assume that you don't care about the exact time - so any time
on the 25th of a 30-day month will return "6 days" to the 1st of the next
month whether you're asking at midnight or at 10 pm. The version here is for
OS 9 and later.

set today to (current date)
set time of today to 0 -- midnight
set thisMonth to month of today
copy today to nextMonth

set monthList to {January, February, March, April, May, June, July,
August, September, October, November, December}
repeat with i from 1 to 12
if thisMonth = item i of monthList then
if i /= 12 then
set month of nextMonth to item (i + 1) of monthList
else
set month of nextMonth to January
set year of nextMonth to (year of today) + 1
end if
exit repeat
end if
end repeat

set diff to (nextMonth - today) / days as integer

Or how about this:

set today to (current date)
copy today to nextMonth
set day of nextMonth to 28
set nextMonth to nextMonth + 4 * days
set day of nextMonth to 1
(nextMonth - today) / days div 1


-boo
_______________________________________________
applescript-users mailing list | email@hidden
Help/Unsubscribe/Archives: http://www.lists.apple.com/mailman/listinfo/applescript-users
Do not post admin requests to the list. They will be ignored.


References: 
 >Re: Need help with finding first of the month (From: Paul Berkowitz <email@hidden>)

  • Prev by Date: Re: Sorry
  • Next by Date: Re: Sorry
  • Previous by thread: Re: Need help with finding first of the month
  • Next by thread: Re: Need help with finding first of the month
  • Index(es):
    • Date
    • Thread