Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 
rsimson1
Contributor II
Contributor II

Calculate the age of people on a specific date

Hi,

I need to calculate the age of people on a specific date. 31st December 2016. I already have the DOB and age of people in my data. Can anybody help?

Thanks

6 Replies
vishsaggi
Champion III
Champion III

Try age function.

Like

age(timestamp, date of birth);

age('2016-12-31', DOB)

dineshm030
Creator III
Creator III

Hi Richard,

You can calculate the age of people in two types.

1. Floor((Date('2016-12-31')-DOB)/365)

2. Age('31-12-2016',DOB)

Timestamp is not important. U can write any format.

Regards,

Dinesh Kumar M

maxgro
MVP
MVP

age(makedate(2016,12,31), DOB)

rsimson1
Contributor II
Contributor II
Author

Below is the script but its still returning only null values.... Further help would be appreciated.


LOAD 1 as PersonIDCounter,
P_ID as PersonID,
P_REFERENCE as [Person Reference],
P_SURNAME as Surname,
P_FORENAMES as Forename,
P_FORENAMES & ' ' & P_SURNAME as [Full Name],
applymap('GenderMap',P_GENDER , 'Missing') as Gender,
P_DOB,
age(today(), [P_DOB]) AS [Person Age],
age(MakeDate('2015,09,31'), [P_DOB]) as [Person summer school leaving age 2015],
P_PERSONADDRESS as AddressID,

vishsaggi
Champion III
Champion III

In your code for age remove the single quotes

What is your [P_DOB] format (I mean is it 'MM/DD/YYYY' or 'YYYY-MM-DD' etc...)

like age(MakeDate(2015,09,31), [P_DOB]) as [Person summer school leaving age 2015]


NickHoff
Specialist
Specialist

Year(DateFieldToCalculate) - Num(Right(P_DOB,4))AS Person Age

Edit:  Switch the Right to Left depending on if your date is formatted with the year first or last.