Calculating age

dunbarx at aol.com dunbarx at aol.com
Fri Jun 27 00:12:07 EDT 2014


Hi.


There would be a problem with certain date ranges. Think of thie variation of your script:



on mouseUp
   convert "1/14/1951" from date to seconds
   put it into dateone
   convert "1/14/1956"  from date to seconds
      put it into datetwo


put datetwo - dateone into age -- calculate the age in seconds
-- divide by the number of seconds per year
put 60*60*24*365.25 into secs_per_year
answer trunc(age / secs_per_year) 


end mouseUp


Its the leap years. You claculate seconds, (and even do the 365.25 thing) but that value may not "close" a leap year if it falls in the wrong place.


Craig Newman








convert dateone from date to seconds
convert datetwo from date to seconds
put datetwo - dateone into age -- calculate the age in seconds
-- divide by the number of seconds per year
put 60*60*24*365.25 into secs_per_year
put the trunc of (age / secs_per_year) into age





-----Original Message-----
From: Mark Smith <Mark_Smith at cpe.umanitoba.ca>
To: use-revolution <use-revolution at lists.runrev.com>
Sent: Thu, Jun 26, 2014 10:45 pm
Subject: Calculating age


Hi, does anyone know how to calculate someones age in years from two dates?

Currently I am doing something kludgy like:

convert dateone from date to seconds
convert datetwo from date to seconds
put datetwo - dateone into age -- calculate the age in seconds
-- divide by the number of seconds per year
put 60*60*24*365.25 into secs_per_year
put the trunc of (age / secs_per_year) into age

But I suspect it is only approximate.

Thanks



--
View this message in context: http://runtime-revolution.278305.n4.nabble.com/Calculating-age-tp4680687.html
Sent from the Revolution - User mailing list archive at Nabble.com.

_______________________________________________
use-livecode mailing list
use-livecode at lists.runrev.com
Please visit this url to subscribe, unsubscribe and manage your subscription 
preferences:
http://lists.runrev.com/mailman/listinfo/use-livecode

 



More information about the use-livecode mailing list