Skip to main content
Announcements
Qlik Connect 2024! Seize endless possibilities! LEARN MORE
cancel
Showing results for 
Search instead for 
Did you mean: 
Meg00
Contributor III
Contributor III

Help with date and age

Hi,

Im struggling to find a way to convert a number to date and then date to age. I have numbers that look like YYMMDDXXXX where Id like to use the date and from that get the age of the person. So first off, how du I exclude the last 4 numbers and add "19" to the year? And then how do I calculate age today from the date?

Pls help...

1 Solution

Accepted Solutions
CELAMBARASAN
Partner - Champion
Partner - Champion

Hi

     Try with this expression

     MakeDate(left(Field,2),Mid(Field,3,2),Mid(Field,5,2)) as Date

     Age(Today(),MakeDate(left(Field,2),Mid(Field,3,2),Mid(Field,5,2))) as Age


     or

    Date(Date#('19'&LEFT(Field,6),'YYYYMMDD')) AS Date

     Age(Today(),Date#('19'&LEFT(Field,6),'YYYYMMDD')) AS Age

Use the one which is comfortable for you

Celambarasan

View solution in original post

4 Replies
marcos
Partner - Contributor III
Partner - Contributor III

this should do what you need

Date(Date#(LEFT(Date_Field,6),'YYMMDD')) AS New_Date
Age(Today(),Date#(LEFT(Date_Field,6),'YYMMDD')) AS Age_Field

Meg00
Contributor III
Contributor III
Author

Seems to work!

Thank you!!

CELAMBARASAN
Partner - Champion
Partner - Champion

Hi

     Try with this expression

     MakeDate(left(Field,2),Mid(Field,3,2),Mid(Field,5,2)) as Date

     Age(Today(),MakeDate(left(Field,2),Mid(Field,3,2),Mid(Field,5,2))) as Age


     or

    Date(Date#('19'&LEFT(Field,6),'YYYYMMDD')) AS Date

     Age(Today(),Date#('19'&LEFT(Field,6),'YYYYMMDD')) AS Age

Use the one which is comfortable for you

Celambarasan

Meg00
Contributor III
Contributor III
Author

Yeah, that solved the problem with the year converting to 2000s instead of 1900s, thank you very much!