Determining one's age

  • Thread starter Thread starter Jim Gudaitis
  • Start date Start date
J

Jim Gudaitis

I figured out my own question. Below is the solution for
any who are interested:

Age: IIf(DatePart('y',[birthdate])<=DatePart('y',Date
()),DatePart('yyyy',Date())-DatePart('yyyy',
[BIRTHDATE]),DatePart('yyyy',Date())-1-DatePart('yyyy',
[BIRTHDATE]))

If you see a flaw, let me know.

Jim
 
There's always the simple math method of:
(date() - dtmDOB) / 365.25
:)

Jim Gudaitis said:
I figured out my own question. Below is the solution for
any who are interested:

Age: IIf(DatePart('y',[birthdate])<=DatePart('y',Date
()),DatePart('yyyy',Date())-DatePart('yyyy',
[BIRTHDATE]),DatePart('yyyy',Date())-1-DatePart('yyyy',
[BIRTHDATE]))

If you see a flaw, let me know.

Jim
-----Original Message-----
If I have a birthdate value, how would I write a query
that would give me a person's current age? In my first
effort, I used DatePart to extract the year and subtracted
that from the current year. I want to be more accurate
than that. Any suggestions?

Jim Gudaitis
.
 
I like the simplicity of this. I had to add the Int
function to your solution to return a whole number, but it
works beautifully. Thanks.

It's simple but... unfortunately, it's often wrong for one or two days
around the birthdate.

An absolutely reliable age algorithm:

Age: DateDiff("yyyy", [DOB], Date()) - IIF(Format([DOB], "mmdd") >
Format(Date(), "mmdd"), 1, 0)
 
Back
Top