Age of Patient

H

Heather

I need help. I'm new at this and I'm trying to write a facesheet and
armband that will calculate the age and also put it in Years, Months,
and Days. Here is what I have so far but the problem is that it
putting it in years. I at a loss on what to do to get the month and
day.

select
ACCT_REC.ACCT_NUM as acctBC,
ACCT_REC.ACCT_NUM,
REG_REC.PATIENT_DISPLAY_NAME,
REG_REC.RACE,
YEAR(TODAY()) - YEAR(REG_REC.DOB) - CASE WHEN month(TODAY()) >
month(REG_REC.DOB) THEN 0 WHEN month(TODAY()) < month(REG_REC.DOB)
THEN 1 WHEN day(TODAY()) < day(REG_REC.DOB) THEN 1 ELSE 0 END as
"Age",
REG_REC.DOB,
PRSNEUP.ID as phybc,
PRSNEUP.ID as MRN,
ASSOCTP.DISPLAY_NM

From
((ACCT_REC INNER JOIN
REG_REC ON ACCT_REC.ACCT_PTPTR = REG_REC.PTPTR )
LEFT OUTER JOIN
ASSOCTP ON ACCT_REC.ACCT_PRIMARY_PROV = ASSOCTP.NUM )
INNER JOIN
PRSNEUP ON REG_REC."#" = PRSNEUP.PERSON_NUM
where
PRSNEUP.ID > 10000
and
ACCT_REC.ACCT_NUM = $()
 
F

fredg

I need help. I'm new at this and I'm trying to write a facesheet and
armband that will calculate the age and also put it in Years, Months,
and Days. Here is what I have so far but the problem is that it
putting it in years. I at a loss on what to do to get the month and
day.

select
ACCT_REC.ACCT_NUM as acctBC,
ACCT_REC.ACCT_NUM,
REG_REC.PATIENT_DISPLAY_NAME,
REG_REC.RACE,
YEAR(TODAY()) - YEAR(REG_REC.DOB) - CASE WHEN month(TODAY()) >
month(REG_REC.DOB) THEN 0 WHEN month(TODAY()) < month(REG_REC.DOB)
THEN 1 WHEN day(TODAY()) < day(REG_REC.DOB) THEN 1 ELSE 0 END as
"Age",
REG_REC.DOB,
PRSNEUP.ID as phybc,
PRSNEUP.ID as MRN,
ASSOCTP.DISPLAY_NM

From
((ACCT_REC INNER JOIN
REG_REC ON ACCT_REC.ACCT_PTPTR = REG_REC.PTPTR )
LEFT OUTER JOIN
ASSOCTP ON ACCT_REC.ACCT_PRIMARY_PROV = ASSOCTP.NUM )
INNER JOIN
PRSNEUP ON REG_REC."#" = PRSNEUP.PERSON_NUM
where
PRSNEUP.ID > 10000
and
ACCT_REC.ACCT_NUM = $()

If you are looking to compute years, months and days, take a look at:

"A More Complete DateDiff Function" at
http://www.accessmvp.com/djsteele/Diff2Dates.html

which will do all 3 using just the one function, i.e. 25 years 4
months 15 days,
 
Top