Mailing Lists: Apple Mailing Lists

Image of Mac OS face in stamp
 
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: date and age



Title: Re: date and age
On 3/26/05 9:12 AM, "Brian" <email@hidden> wrote:


There is a simple way to do that :  

set b_date to date "29/02/1980"

set a_date to (current date)

return (a_date - b_date) div (weeks * 52)
 
You think so? Try it for today being Feb 24, 2005. The answer will be 25, which is incorrect. The reason is that there are more than 52 weeks to a year. Even using (days * 365) will sometimes be incorrect, since some years have 366 days.


If you want a more accurate number, just change 'div' in '/'.

That's guaranteed to be inaccurate for every script run, and also to give a rather incomprehensible result with decimal fractions of a year expressed in +E scientific notation, to boot. Who thinks in terms of decimal fractions of a year? Converting the remainder to days, hours, etc. will be similar to what Robert's script did, but longer.

Just do it the way Robert did in the first place, and it will be accurate, as Matt said.

--
Paul Berkowitz
 _______________________________________________
Do not post admin requests to the list. They will be ignored.
Applescript-studio mailing list      (email@hidden)
Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/applescript-studio/email@hidden

This email sent to email@hidden

References: 
 >Re: date and age (From: Brian <email@hidden>)



Visit the Apple Store online or at retail locations.
1-800-MY-APPLE

Contact Apple | Terms of Use | Privacy Policy

Copyright © 2007 Apple Inc. All rights reserved.