Age calculation script
    Roger.E.Eller at sealedair.com 
    Roger.E.Eller at sealedair.com
       
    Fri Sep  8 09:55:52 EDT 2006
    
    
  
2006/9/8, Mark Smith <mark at maseurope.net>:
> function getAge bDay
>    put 60 * 60 * 24 * 365 into secsPerYear
>    put secsPerYear / 12 into secsPerMonth
>
>    put the seconds into tDay
>
>    -- assuming date of birth is given in short system date format
>    convert bDay from short system date to seconds
>
>    put tDay - bDay into tAgeInSecs
>
>    put tAgeInSecs div secsPerYear into tYears
>    put (tAgeInSecs mod secsPerYear) div secsPerMonth into tMonths
>
>    return tYears && tMonths
> end getAge
>
> This is pretty rough and ready, it doesn't try to take into account
> leap years and so-on, but unless the person is really old (100 yrs
> + ?), it should be close enough. Also, see 'centuryCutoff' in the
> docs if you're going to be dealing with older people.
>
>
> Best,
>
> Mark
Very nice!  It is interesting though, that early dates will return strange 
results.  The date 9/1/1906 will result in 0 years and 0 months old.
Roger Eller <roger.e.eller at sealedair.com>
    
    
More information about the use-livecode
mailing list