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

Date difference with respect to today's date

Hi all,

I have to calculate the date difference with reference to today() in terms of years,months and days

please let me how to achieve this in qlik sense.

Regards,

Arun

1 Solution

Accepted Solutions
mkelemen
Creator III
Creator III

Hi,

this formula should work for short time differences.

=Year(Today() - datecol + 1) - 1900 & ' Years, '

& Num(Month(Today() - datecol + 1) - 1) & ' Months, '

& Day(Today() - datecol + 1) & ' Days'

Two things:

     it gives incorrect result for datecol = Today - simple if can solve that

     it gives you one extra day for each Leap Day - this seems to be much harder to solve...

BR,

  Matus

View solution in original post

9 Replies
sunny_talwar

What is the expected output?

Not applicable
Author

expected output for '28-Dec-14' - '20-Dec-16' is 2 years, 0 months,8days

lakshmikandh
Specialist II
Specialist II

Interval(now() - Datecolumn,'YY')

Interval(now() - Datecolumn,'MM')

Interval(now() - Datecolumn,'DD')

sunny_talwar

Interval can give out Year and Month? I don't think Interval can do this unless this is something new?

anat
Master
Master

you can try like this ,but this is not recommended.

( year(Today())- year(datecol))&'Years :'&( month(Today())- month(datecol))&'Months : '&( Day(Today())- Day(datecol))&'Days '

mkelemen
Creator III
Creator III

It gives 1 year, -11 months, -30 days between 2016/01/01 and 2015/12/31.

It is technically correct but not usable...

BR,

  Matus

swuehl
MVP
MVP

Maybe something along this?

Age in Year Month Day Format

mkelemen
Creator III
Creator III

Hi,

this formula should work for short time differences.

=Year(Today() - datecol + 1) - 1900 & ' Years, '

& Num(Month(Today() - datecol + 1) - 1) & ' Months, '

& Day(Today() - datecol + 1) & ' Days'

Two things:

     it gives incorrect result for datecol = Today - simple if can solve that

     it gives you one extra day for each Leap Day - this seems to be much harder to solve...

BR,

  Matus

Not applicable
Author

Thank you matus kelemen

it worked for me..