Mailing Lists: Apple Mailing Lists

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

date and age



Hi all,
Maybe this is an applescript question but I am in the middle of my ASS app with a table with columns for a date (birth date) and age. I want the age column to show the correct age of a person born on date b_date. The simple solution below won't work over long periods of time because of leap years: Yours, Rob D


((Current date) - b_date) /days/365 -- won't be accurate in the long run

--more complex solution below which works for me but..
--On other machine people get an error "can't make month into a number etc"


set xx to (current date)
set yy to b_date
set ee to (year of xx) - (year of yy)
if (year of xx) = (year of yy) then
set theage to 0
else if (month of xx) - (month of yy) > 0 then
set theage to ee
else if (month of xx) = (month of xx) and (day of xx)- (day of yy) > 0 then
set theage to ee
else
set the theage to ee - 1
end if
return ee --the actual age of the person


--I could coerce (month of xx) to integer and maybe that will solve the error but I am wondering if there is a simpler method ("Call method"? or other) for this simple calculation.

_______________________________________________
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


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.