Getting someone's age from dob and current year

Admin admin at mfelkerco.com
Sun Jul 31 14:33:18 CDT 2011


  

Thanks everyone. I figured the dob problem out and it's now
working. Now I just need to get my substack back. Have there been
stability problems with substacks? 

Mike 

On Sun, 31 Jul 2011 11:32:02
-0400, Peter Brigham MD wrote: 

> On Jul 31, 2011, at 12:03 AM, Warren
Samples wrote:
> 
>> On Saturday, July 30, 2011 07:16:44 PM Roger Eller
wrote: 
>> 
>>> convert tToday to seconds convert tBorn to seconds
>>
It's been talked about before, but this calls for a reminder: attempting
to convert a date prior to Jan 1, 1970 to "seconds" returns "invalid
date" instead of a number in Windows. Don't do this if you are going to
need this to work in Windows! Under Windows, you need to subtract the
birthyear from the current year and determine if the current month/day
is later than the birth month/day and subtract one year if necessary.
Conveniently, this methods does work on all platforms.
> 
> function
doAge tDOB
> -- assumes format of m/d/yy
> set the itemdelimiter to
"/"
> put item 3 of tDOB into DOByr
> put item 2 of tDOB into DOBmo
>
put item 1 of tDOB into DOBdy
> put item 3 of the short date into
nowYr
> put item 2 of the short date into nowMo
> put item 1 of the
short date into nowDy
> if DOByr > nowYr then -- prev century
> --
assumes no one with age > 100
> put "19" before DOByr
> else
> put "20"
before DOByr
> end if
> put "20" before nowYr
> put nowYr - DOByr into
tAge
> if nowMo > DOBmo then return tAge
> if nowMo < DOBmo then return
tAge -1
> if nowDy < DOBdy then return tAge -1
> return tAge
> end
doAge
> 
> -- Peter
> 
> Peter M. Brigham
> pmbrig at gmail.com [1]
>
http://home.comcast.net/~pmbrig [2]
> 
>
_______________________________________________
> use-livecode mailing
list
> use-livecode at lists.runrev.com [3]
> Please visit this url to
subscribe, unsubscribe and manage your subscription preferences:
>
http://lists.runrev.com/mailman/listinfo/use-livecode [4]

 


Links:
------
[1] mailto:pmbrig at gmail.com
[2]
http://home.comcast.net/~pmbrig
[3]
mailto:use-livecode at lists.runrev.com
[4]
http://lists.runrev.com/mailman/listinfo/use-livecode


More information about the use-livecode mailing list