Calculating age

Mike Bonner bonnmike at gmail.com
Fri Jun 27 01:01:19 EDT 2014


Since you only need straight years, subtract the birth year from the
current date then a simple switch statement to adjust for whether the
birthdate has been met for the year should work fine. Something like:

switch
   case check to see if the month now  < month of the birthdate
   if so, subtract 1 from tYears
   break
case if the month now  = the month of the birthdate tBdate) and the day now
 < the day of the birthdate
   if so, subtract 1 from tYears
   break
end switch

Also, curious now.  Can you convert dates to seconds if they're before the
epoch?  Its not working for me in 6.6.2.  Anything after 1970 works fine.


On Thu, Jun 26, 2014 at 10:57 PM, Charles E Buchwald <charles at buchwald.ca>
wrote:

> Check out Sarah Reichelt's Date & Time Library.
> It makes this easy, as well as several other useful time and date
> calculations.
> Cheers,
> - Charles
>
> On 26 Jun 2014, at 9:44 PM, Mark Smith <Mark_Smith at cpe.umanitoba.ca>
> wrote:
>
> > 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
>
> --
> Charles E. Buchwald
> CEO/Director General
> Museografica Digital
> http://digital.museografica.com
>
> LC Developer Tools: http://buchwald.ca/developer-tools/
>
> Email Notice: http://wp.me/P3aT4d-33
>
>
> _______________________________________________
> 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