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

How to calculate difference between two dates in months - rounding to 1 decimal place


I am trying to calculate the difference in months between two dates but needing to round to one decimal place.  I found the below on the forum, but do not understand the format.  It is returning the number rounded.

Needing the difference between today and EFFECTIVE_DATE rounded to 1 decimal place.

year(today(2))*12)+month(today(2))) - (((year(EFFECTIVE_DATE)*12)+month(EFFECTIVE_DATE)))

Thank you!

3 Replies
sunny_talwar

triciagdaly
Contributor III
Contributor III
Author

I was hoping for an explanation of the formula I sent.  Thanks anyway.

swuehl
MVP
MVP

Since your formula just calculates difference between two integers (using sequential month numbers started in Jan 0000 for two dates), you can't calculate something with significant decimal places from that.

Here is a thread that covers some alternatives and also tries to explain the difficulty in defining a 'month' distance between dates:

How Do I Get the Number of Months Between Two Dates?

edit:

And if you want a more accurate calculation of date difference in Year,Month, Days, maybe use something like

day month year shows two dates qlikview