Age calculation script

Graham Samuel livfoss at mac.com
Sat Sep 9 16:18:25 EDT 2006


On Fri, 8 Sep 2006 14:22:43 +0200,  "William de Smet"  
<wdesmet at wanadoo.nl> wrote:

> Hi there,
>
> For an educational app I want to calculate someone's age based on date
> of birth and todays date but I don't know how to start!
> I made a field in which the user puts its 'date of birth' (dd/mm/yy)
> and a button that needs to compare 'todays date' and the 'date of
> birth'.
> The output needs to be : age and months (and days?)


It's late and maybe I have missed the point, but why have all the  
scripts in this thread been so complicated? William seems to want  
answers like "20 years, 6 months and three days".  If one knows the  
year of a person's birth - which can easily be converted into a full  
4-digit number, and one knows the current year (ditto), then by  
subtraction one knows the number of years the person has been alive.  
After that, all you need to know is whether the person's birthday has  
already occurred this year or not, and the number of days (365 or  
366) in this year. AFAIK, what we mean by "20 years, 6 months and 3  
days" is actually "6 months and three days after his/her 20th  
birthday": it is not necessary to count precisely the number of days  
the person has been alive. What did I miss in thinking like this?

Graham


----------------------------------------
Graham Samuel / The Living Fossil Co. / UK and France




More information about the use-livecode mailing list