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

Announcements
See why IDC MarketScape names Qlik a 2025 Leader! Read more
cancel
Showing results for 
Search instead for 
Did you mean: 
usama_waqar94
Contributor II
Contributor II

Date issue while calculating age using AGE()

Hello,

I have a scenario to calculate Age in years from DOB which I am doing using Age(Today(),DOB). The oracle source date format is 'DD-MMM-YY' & datatype is NVARCHAR2(100). 

While using Age(Today(),DOB) expression I am able to get correct years except DOB dates below 01-JAN-73 as qliksense is reading 73(YY) as 2073 and same for 72,71,70 etc as 2072,2071,2070 because of which is showing in negative like -49,-48 so on..

I tried to fix date format within qliksense hence the format is changing but year issue is still there and tried below logics:

1- Date format: date(date#(DOB,'DD-MMM-YY'),'DD/MM/YYYY')   AS DOB_NEW 

2- Date format_2: date(date#(DOB,'DD-MMM-YY'),'M/D/YYYY')   AS DOB_NEW2  

3- IF (Date format: date(date#(DOB,'DD-MMM-YY'),'DD/MM/YYYY') > '01/01/2026' , 

date(date#(DOB,'DD-MMM-YY'),'DD/MM/19YY') , date(date#(DOB,'DD-MMM-YY'),'DD/MM/YYYY')   ) (Logic - to fix the year issue but still dates below 01-JAN-73 showing years as 2073 which should be 1973)

 

Appreciate community support.

@hic @sunny_talwar @tresesco @Miguel_Angel_Baeyens @swuehl @maxgro 

Labels (6)
7 Replies
TheLazyDeveloper
Contributor III
Contributor III

Interesting issue, are you able to get the numeric date values from oracle? That should clear this issue up. If not you could try updating the dates in the script to display as 'DD-MM-YYYY' before apply the age function so Qlik knows the correct format.



https://community.qlik.com/t5/Visualization-and-Usability/DOB-column-is-showing-future-dates-that-ar...

usama_waqar94
Contributor II
Contributor II
Author

hi @TheLazyDeveloper ,

I am not getting even the numeric date values. I am getting dates as 'DD-MMM-YY' format.

Also, I have tried your attached solution but still the issue is same.

 

Thank

Prashant_Naik20
Contributor III
Contributor III

Hi, 

try this format - date(date#(DOB,'DD-MMM-YY'),'DD-MMM-YYYY')

usama_waqar94
Contributor II
Contributor II
Author

Yes, already tried but same results

Chanty4u
MVP
MVP

Try this 

Convert your date format 

DOB_Interpreted:

LOAD

    *,

    Date#(DOB_Field, 'DD.MM.YYYY') as DOB_Date

FROM YourSource;

LOAD

    *,

    age(Today(), DOB_Date) as AgeYears

Resident DOB_Interpreted;

 

 

Front end chat

= age(Today(), DOB_Date)

 

 

 

 

usama_waqar94
Contributor II
Contributor II
Author

Hi @Chanty4u,

Still the years output is same showing negative years as its taking years < 73 as 2073 etc. 

marcus_sommer

The issue isn't related to age() or date#() else to the fact that the year-information isn't complete - without an included century the date-conversion must make a guess. If I remember old community stuff right its hard-coded in the relevant library and goes around 50 years in this and in that direction (AFAIK not from today else the Qlik or library release date or similar).

IMO any attempt to adjust this logic isn't sensible else I suggest to implement a check-logic in regard to your data-set. There are surely various information included which could be used to check the century.

A simpler way may be to apply something like this:

if(age(today(), MyDate) >= 0, age(today(), MyDate),
   age(today(), makedate(year(MyDate))-100, month(MyDate), day(MyDate))))