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
converting seconds to age
Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller
-
- VIP Livecode Opensource Backer
- Posts: 931
- Joined: Thu Nov 13, 2008 6:48 am
converting seconds to age
macOS 12.6.5 (Monterey), Xcode 14.2, LC 10.0.0, iOS 15.6.1
Targets: Mac, iOS
Targets: Mac, iOS
Re: converting seconds to age
Hi Mark,
I found a scripts on my HD to get the num of days between two date
Best regards
Jean-Marc
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
Jean-Marc
https://alternatic.ch
-
- VIP Livecode Opensource Backer
- Posts: 931
- Joined: Thu Nov 13, 2008 6:48 am
Re: converting seconds to age
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
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
macOS 12.6.5 (Monterey), Xcode 14.2, LC 10.0.0, iOS 15.6.1
Targets: Mac, iOS
Targets: Mac, iOS
Re: converting seconds to age
365.25 is accurate to 0.01 days, or about 15 minutes. This should do.
Craig Newman
Craig Newman
-
- VIP Livecode Opensource Backer
- Posts: 931
- Joined: Thu Nov 13, 2008 6:48 am
Re: converting seconds to age
dunbarx wrote:365.25 is accurate to 0.01 days, or about 15 minutes. This should do.
Craig Newman
Reassuring. Thanks
-- Mark
macOS 12.6.5 (Monterey), Xcode 14.2, LC 10.0.0, iOS 15.6.1
Targets: Mac, iOS
Targets: Mac, iOS