Calculate age MONTHLY

G

Guest

Dear all,

I must caculate the age monthly.

For example, A's birthday is 1980/01/01. On Feb, A is 25.18 years old;
on Mar, A
is 25.26 years old;
on Apr, A
is 25.35 years old, ... and so on..

How can I write the expression to calculate his age at the same query?

Thank you for help...
 
G

Guest

Int(Age) will give you the years, and Int((Int(Age) - Age) * 12) will give
you the months. Round((Int(Age) - Age) * 12,0) will give you the same result
but will be rounding to the nearest month instead of simply stripping the
decimal part off. You would have to test a little, but I think they will both
be the same as long as the amount after the decimal is always less than 1/2
(.5). Just be sure to use the Int portion to get the years, or 25 years, 7
months will become 26 years, which you don't want.

The Int function simply drops everything after the decimal point so that, in
your examples:

The year portion of 25.18 is 25 years. The month portion is Int((25.18 - 25)
* 12) = Int(2.16) = 2 months
The year portion of 25.26 is 25 years. The month portion is Int((25.26 - 25)
* 12) = Int(3.12) = 3 months
The year portion of 25.35 is 25 years. The month portion is Int((25.35 - 25)
* 12) = Int(4.2) = 4 months
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top