Skip to main content
Announcements
Live today at 11 AM ET. Get your questions about Qlik Connect answered, or just listen in. SIGN UP NOW
cancel
Showing results for 
Search instead for 
Did you mean: 
soniasweety
Master
Master

four years

Hi all I want to calculate the age of less than 4years and  greater than 4yeras like attached how to calculate

1 Solution

Accepted Solutions
tresesco
MVP
MVP

Age() is there in qlik. Try like:

If(Age(today(), yourdate)>=4, '>= four', '< four')

View solution in original post

8 Replies
olivierrobin
Specialist III
Specialist III

hello,

something like this

if(Today()-MyDate>365*4-1,'gt than 4 years',

'less than 4 years')

YoussefBelloum
Champion
Champion

Hi,

tell us more about your data structure? what is your date field type ?

do you calculate the age from a range of dates or you are comparing with today date ?

soniasweety
Master
Master
Author

My date field is

started_on    = 10/26/2016 2:07:02 AM

yes its based on today date

tresesco
MVP
MVP

Age() is there in qlik. Try like:

If(Age(today(), yourdate)>=4, '>= four', '< four')

sasiparupudi1
Master III
Master III

=Date(Addyears(Date#('10/26/2016 2:07:02 AM','MM/DD/YYYY h:mm:ss TT'),4))>Today()

YoussefBelloum
Champion
Champion

=if(Date(started_on)-AddYears(Timestamp(today()),-1)<1460,'less tha...','greater than..')

soniasweety
Master
Master
Author

done change in expression this is also working

if(((Date(Today(),'DD-MM-YYYY')

    -Date(Floor(Num([My_date])),'DD-MM-YYYY'))/365)>4,'Greater than 4 years','Lesser than 4 years') as by_Age,

tresesco
MVP
MVP

I see few unnecessary (majorly formatting) functions, you can get rid of. The equivalent would be:

if((Today()-[My_date])/365>4,'Greater than 4 years','Lesser than 4 years') as by_Age,