• 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: A Difference of Months
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: A Difference of Months


  • Subject: Re: A Difference of Months
  • From: Arthur J Knapp <email@hidden>
  • Date: Wed, 13 Mar 2002 09:59:43 -0500

> Date: Wed, 13 Mar 2002 11:50:28 +1100
> Subject: Re: A Difference of Months
> From: Shane Stanley <email@hidden>

> On 13/3/02 8:55 AM +1000, Arthur J Knapp, email@hidden, wrote:
>
>> So I need to find how many months difference there are between any
>> two dates.

>> Months are not as simple, however, because they have a differing
>> number of days.

> If you're happy to disregard days, why not just get the number of months of
> each date by multiplying the years by 12 and adding the current month:

> on getMonths(theDate)
> copy theDate to b
> set month of b to January
> set theMonths to ((year of theDate) * 12) + (1 + (theDate - b + 1314864)
> div 2629728)
> return theMonths

Thank you Shane, this is brilliant and so simply. :)

Simply multiplying a year by 12 gives a total month count from
the turn of the century, from there, we adjust for "whole" month
differences in the two dates.



{ Arthur J. Knapp, of <http://www.STELLARViSIONs.com>
<mailto:email@hidden>
try
<http://www.appleklub.cz/~koudelka/home.shtml>
on error number -128
end try
}
_______________________________________________
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.

  • Follow-Ups:
    • Re: A Difference of Months
      • From: Shane Stanley <email@hidden>
  • Prev by Date: scripting a browser (newbie)
  • Next by Date: Re: Crunch numbers
  • Previous by thread: Re: A Difference of Months
  • Next by thread: Re: A Difference of Months
  • Index(es):
    • Date
    • Thread