calculating exact age and workingyears
Kenneth Brody
kenbrody at bestweb.net
Wed Nov 24 12:13:59 PST 2004
Peter Klaassen - NCC vof wrote:
[...]
> > And why do you subtract 1 from the fields if today is prior to the
> > anniversary?
>
> because before someones birthday he still is in your case 43 and not
> 44.
[...]
> > Perhaps if you can explain exactly what you are trying to calculate?
>
> I want to show the exact age in years everyday in iua.
>
> > If tomorrow were my 44th birthday, what number do you want?
>
> 43 today and 44 tomorrow
>
> > What if I were born on January 1st, and today was December 31st?
>
> 44 of course
Okay, so you want to say that someone is 43 up until their 44th birthday,
even if they are 43 years and 364 days old, correct?
In that case, don't move to a .0 field, as that will round. (This is
probably the cause of your problems, though you haven't given a specific
example of a "wrong" calculation.) Rather, use the INT() function.
Age = int( (Today - Birthday)/"365.25" )
Note that this will, on occasion, be off by one on the day before the
birthday and on the actual birthday, due to the fact that a year is not
exactly 365.25 days. If this is critical, then you will need to add a
little bit of logic to handle these two days.
--
+-------------------------+--------------------+-----------------------------+
| Kenneth J. Brody | www.hvcomputer.com | |
| kenbrody/at\spamcop.net | www.fptech.com | #include <std_disclaimer.h> |
+-------------------------+--------------------+-----------------------------+
Don't e-mail me at: <mailto:ThisIsASpamTrap at gmail.com>
More information about the Filepro-list
mailing list