Qlik Community

New to QlikView

Discussion board where members can get started with QlikView.

megalomania
New Contributor II

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...

Tags (2)
1 Solution

Accepted Solutions
Highlighted

Help with date and age

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

4 Replies
marcos
New Contributor III

Help with date and age

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

megalomania
New Contributor II

Help with date and age

Seems to work!

Thank you!!

Highlighted

Help with date and age

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

megalomania
New Contributor II

Help with date and age

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

Community Browser