Page 1 of 1
converting seconds to age
Posted: Thu Jan 19, 2012 7:57 am
by marksmithhfx
Does anyone have code to convert the difference between two dates, in seconds, to years? For example the difference between today and your date of birth expressed as your age?
Thanks
-- Mark
Re: converting seconds to age
Posted: Thu Jan 19, 2012 9:37 am
by jmburnod
Hi Mark,
I found a scripts on my HD to get the num of days between two date
Code: Select all
on tNumDaysBetweenDates
put NumDaysBetweenDates("1/19/6","1/19/12")
end tNumDaysBetweenDates
function NumDaysBetweenDates pStartDay,pEndDay
put empty into rNumDaysBetweenDates
put pStartDay into depDate
put pEndDay into ArrDate
put depDate into UnedateD
convert unedateD to seconds
put ArrDate into UnedateA
convert unedateA to seconds
put unedateA-unedateD into difSec
put difSec/86400 into rNumDaysBetweenDates
return rNumDaysBetweenDates
end NumDaysBetweenDates
Best regards
Jean-Marc
Re: converting seconds to age
Posted: Fri Jan 20, 2012 2:23 am
by marksmithhfx
Thanks Jean-Marc, good start...
I guess rNumDaysBetweenDates/365.25 should get me pretty close if not exactly to the right answer. I do worry, when reporting age this way, of being off by one day but the errors should be few and minor.
-- Mark
Re: converting seconds to age
Posted: Fri Jan 20, 2012 2:59 am
by dunbarx
365.25 is accurate to 0.01 days, or about 15 minutes. This should do.
Craig Newman
Re: converting seconds to age
Posted: Fri Jan 20, 2012 3:44 am
by marksmithhfx
dunbarx wrote:365.25 is accurate to 0.01 days, or about 15 minutes. This should do.
Craig Newman
Reassuring. Thanks
-- Mark