Do not input private or sensitive data. View Qlik Privacy & Cookie Policy.
Skip to main content

Announcements
ALERT: QlikView server communication interruptions following Microsoft Windows Domain Controller security updates
cancel
Showing results for 
Search instead for 
Did you mean: 
Anonymous
Not applicable

Age Function

Hey There,

i use on my data model at the age function & Interval for some reason i get not the right age, any idea what im doing wrong ?

On sql servel i use this "DATEDIFF(Year,E.BirthDate,GetDate()) EmployeeAge" but i know datediff does not work on qv so i try this other method.

Regards

David

Capture.JPG

Labels (1)
12 Replies
swuehl
Champion III
Champion III

Are you talking about applying Age() to dates before year 1582, i.e. start of the gregorian calendar?

I believe QV will keep to the gregorian calendar and apply it's rules to the time before it was introduced (proleptic calendar). But I haven't tested it (haven't worked with databases containing these dates so far).

If your question is a concern about leap year handling, what concerns do you have exactely?

lawrenceiow
Creator II
Creator II

swuehl‌, my issue is simply to do with calculating a persons age. From my understanding (which may not be that great) dividing the days by 365.25 would be good enough for the living as it gains 1 day in 128 years. So in calculating the age which include the deceased I've since used 365.2425

Instead of using formulae such as

   floor((eventDate-DateOfBirth)/365.2425) as PersonAge

I thought it might be neater to use

   age(eventDate, DateOfBirth) as PersonAge

So, I just wanted to check that it would be safe to use this function.

Thanks for your help.

swuehl
Champion III
Champion III

I think the Age() function is more accurate in returning an integer number that is commonly regarded as age, i.e. increased by 1 each year whenever the day and month of the DateOfBirth value is reached.