How to Calculate Age

M

mike

I need to calculate age of customers based on their date of births?
Any kind of help will be greatly appreciated.

Thanks in advance
Mike
 
F

fredg

I need to calculate age of customers based on their date of births?
Any kind of help will be greatly appreciated.

Thanks in advance
Mike

In a query:
Age: DateDiff("yyyy", [DOB], Date()) - IIF(Format([DOB], "mmdd") >
Format(Date(), "mmdd"), 1, 0)

Directly as the control source of an unbound control:
=DateDiff("yyyy",[DOB],Date())-IIf(Format([DOB],"mmdd")>Format(Date(),
"mmdd"),1,0)

You do know, I hope, that this Age computation should NOT be stored in
any table.
Just compute it and display it on a form or report, as needed.
 
M

mike

I just realised that the implication of your words.I really cant store
the computation in the back end.
How can I make those computations get stored in the backend
simultaneously.
Thanks in advance

Mike
 
F

fredg

I just realised that the implication of your words.I really cant store
the computation in the back end.
How can I make those computations get stored in the backend
simultaneously.
Thanks in advance

Mike

There is no reason to store the computation.
If you were to store the age as of today, it is guaranteed to be wrong
at least within a year, possibly as soon as tomorrow.
As long as you have the date of birth stored in your table, compute
the age when needed and it will always be correct.

If the concept of not storing calculated data is difficult for you, I
would suggest you perform a search on past newsgroup messages at
http://www.groups.google.com. An advance search for 'store calculated'
returned 900+ messages since 1/1/2004. See what others have to say.
 
D

Douglas J. Steele

Why do you want to store the age since it's constantly changing?

Put the expression Fred gave you into a query and use the query wherever you
would otherwise have used the table.
 

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