Do not input private or sensitive data. View Qlik Privacy & Cookie Policy.
Skip to main content

Announcements
Want to see what's currently in public preview? We've pulled it all together in one place. Check it out here
cancel
Showing results for 
Search instead for 
Did you mean: 
QFanatic
Creator
Creator

Difference in Months, between 2 dates

hi all

I want to calculate, the difference in months between today() and a CommencementDate in Qlik (true qlik date, format DD/MM/YY)

My statement is "'mm'". 

if CommencementDate  = 12/02/2015, I get 3021120. Obviously thats not right.

if I change the 'mm' to 'M' or 'MM'  i get zero....

what am I doing wrong here?

Thanks

Labels (1)
1 Solution

Accepted Solutions
rubenmarin
MVP
MVP

Hi,I think there is no function to calculate months difference, and interval() function anly allows for days, not months, I would try with something like: =(Age(Today(),CommencementDate)*12)+(Month(Today())-Month(CommencementDate))

View solution in original post

3 Replies
rubenmarin
MVP
MVP

Hi,I think there is no function to calculate months difference, and interval() function anly allows for days, not months, I would try with something like: =(Age(Today(),CommencementDate)*12)+(Month(Today())-Month(CommencementDate))

QFanatic
Creator
Creator
Author

Hello,

I've just stumbled on  round((interval#(Today()-CommencementDate, 'DD')/30.5)) and that seems to work ok.

Thank you very much.

Spartan27215
Partner - Creator
Partner - Creator

How do you handle A Zero value for Age. From day 1 to day 365/366 is year 0 and anything multipleid by that is 0

Example: Age('12/31/2021', '1/1/2021') = 0 and 0 * 12 = 0 where you would really want 1 i.e. 12 if you are looking for months

However

Age('12/31/2021', '1/1/2020') = 2,

Also if you are wanting something like 3 months as a time interval this does not work and dividing by 365 will not always work because of leap years.

Sounds like a DateDiff function should be added just for this purpose so you can specify that you want the interval in Days, Months, Years.