A Difference of Months
A Difference of Months
- Subject: A Difference of Months
- From: email@hidden
- Date: Tue, 12 Mar 2002 22:15:42 EST
This should solve the problem quickly without rotating through each month,
although there could certain (very few, limited - 4 dates per year?)
instances where the combination is inaccurate by a month.
Best Wishes
=-= Marc Glasgow
-- grab the current date
set Now to the current date
-- force the BirthDate variable to record type date by loading the current
date
set BirthDate to the current date
-- change the BirthDate variable to the actual date we want
-- you can substitute a dialog or read from file
set the year of BirthDate to 2001
set the month of BirthDate to October
set the day of BirthDate to 15
-- figure out the number of seconds between the Birthdate and now
set Difference to (Now - BirthDate)
-- convert that number into the number of days between the Birthdate and now
set NumOfDays to (((Difference / 60) / 60) / 24) as integer
if (NumOfDays > 730) then
-- calculate as years
set AgeYears to (round (NumOfDays / 365) rounding down)
set theAge to (AgeYears as string) & " Years old."
else
-- calculate general months using 30.4 days per,
-- then bracketing +/- 1 to find the perfect month
set AgeMonths to (round ((NumOfDays) / 30.4) rounding down)
if ((the day of Now as number) > (the day of BirthDate as number)) then
set AgeMonths to AgeMonths - 1
end if
set theAge to (AgeMonths as string) & " Months old."
end if
display dialog "This patient is " & theAge
_______________________________________________
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.