# Thread: How Do I Calculate a Person's Age?

1. Registered User
Join Date
Jan 2009
Posts
46

## Unanswered: How Do I Calculate a Person's Age?

Hey guys,

I am stuck on this one. I need to run a query that will report a person's current age. I have a field in the database called MBR_BIRTH_DT which stores their birth date. So I wrote this:

YEAR(CURRENT DATE) - YEAR(B.MBR_BIRTH_DT) AS AGE

Then it occured to me that the query has to be more specific. A person with a birthdate occuring after Sept 11 would not be accurate in the query. Any suggestions?

2. Registered User
Join Date
Feb 2008
Location
Japan
Posts
3,483
http://www.dbforums.com/db2/1647177-...-70-older.html

So, just make the right change and you'll the right query:

SELECT A.MBR_SSN_NBR AS SSN,
A.MBR_F_NM AS FIRST_NAME,
A.MBR_L_NM AS LAST_NAME,
CHAR(A.MBR_BIRTH_DT, USA) AS BIRTH_DATE,
YEAR(A.MBR_BIRTH_DT) AS BIRTH_YEAR,
YEAR(CURRENT DATE - date(A.MBR_BIRTH_DT)) as AGE

FROM DSNP.PR01_T_MBR A,
DSNP.PR01_T_MBR_SYS B
where A.MBR_SSN_NBR = B.MBR_SSN_NBR
YEAR(CURRENT DATE - date(A.MBR_BIRTH_DT)) >= 70
and A.MBR_BIRTH_DT > date('0001-01-01')
and B.mbr_stat_cd = '1'

3. Registered User
Join Date
Jul 2009
Location
NY
Posts
963
Thank you tonkuma for your remembering.

What is interesting for me:

Everybody likes the topics with the simple questions, and almost nobody visits the topics with difficult problems.

Is this forum used as resort-spa for the programmers ?

Lenny

4. Registered User
Join Date
Jan 2009
Posts
46
Originally Posted by tonkuma
http://www.dbforums.com/db2/1647177-...-70-older.html

My bad, I should look before posting next time. Sorry!

5. Registered User
Join Date
May 2003
Location
USA
Posts
5,737
Originally Posted by Lenny77
Thank you tonkuma for your remembering.

What is interesting for me:

Everybody likes the topics with the simple questions, and almost nobody visits the topics with difficult problems.

Is this forum used as resort-spa for the programmers ?

Lenny
This forum is often used by students to do their homework assignments.

But "some" of the difficult mathematical "problems" you like to discuss are things that rarely (if ever) occur in the world of a real DBA. They may exist for programmers, but are rarely attempted with SQL language.

#### Posting Permissions

• You may not post new threads
• You may not post replies
• You may not post attachments
• You may not edit your posts
•