Here's what I use:
function doAge bd,asOf
-- bd = birthdate in short date form
-- asOf = (optional) short date
-- age is calculated as of date "asOf"
-- or as of today if omitted
if sws(bd) = "" then
return ""
end if
if asOf = "" then
put the short date into asOf
end if
-- first, get full year (yyyy) for each date
-- I found the centuryCutoff property unreliable
put getFullYr(bd) into actualBdYr
put getFullYr(asOf) into actualNowYr
convert bd to dateItems
put actualBdYr into item 1 of bd
convert asOf to dateItems
put actualNowYr into item 1 of asOf
put item 1 of bd into bYr
put item 2 of bd into bMo
put item 3 of bd into bDy
put item 1 of asOf into nYr
put item 2 of asOf into nMo
put item 3 of asOf into nDy
if bDy > nDy then subtract 1 from nMo
if bMo > nMo then subtract 1 from nYr
put nYr - bYr into age
return age
end doAge
function getFullYr tDate
-- works only for people < 100 years old
set the itemDelimiter to "/"
put the last item of tDate into yr
if the number of chars of yr = 2 then
if yr >= last item of the short date then
put "19" before yr
else
put "20" before yr
end if
end if
return yr
end getFullYr
function sws str
-- "strip whitespace"
return word 1 to -1 of str
end sws
----------------------
On 5/14/09, "[email protected]" wrote:
Hi all,
I could need a hint on how to compute the age of a person when I have
the birthday. The "convert to seconds" and "subtract"ion part is easy,
but how to proceed? :-)
Thanks in advance!
Best
Klaus
_______________________________________________
use-revolution mailing list
[email protected]
Please visit this url to subscribe, unsubscribe and manage your subscription
preferences:
http://lists.runrev.com/mailman/listinfo/use-revolution