Skip to main content
Woohoo! Qlik Community has won “Best in Class Community” in the 2024 Khoros Kudos awards!
Announcements
Nov. 20th, Qlik Insider - Lakehouses: Driving the Future of Data & AI - PICK A SESSION
cancel
Showing results for 
Search instead for 
Did you mean: 
marwen_garwachi
Creator II
Creator II

find a duration in months

Hello,

I need to calculate duration between two dates in months, somone can help me please ?

Exemple :

Start date :  11/07/2007

End Date : 04/11/2013

Elapsed => 75 months 

Thank you

1 Solution

Accepted Solutions
jaimeaguilar
Partner - Specialist II
Partner - Specialist II

Hi,

Try

12*(Year(EndDate)-Year(StartDate))+(Month(EndDate)-Month(StartDate)) )

regards

View solution in original post

6 Replies
Clever_Anjos
Employee
Employee

this should return what you want

=year(vDate1)*12+month(vDate1) -  (year(vDate2)*12+month(vDate2))

Clever_Anjos
Employee
Employee

Or this expression that convert days to months

=  Floor(year(vDate1)*12+month(vDate1)+day(vDate1)/30 

-  (year(vDate2)*12+month(vDate2)+day(vDate2)/30))

marwen_garwachi
Creator II
Creator II
Author

This works but not with all fields i don't know why

=  Floor(year(vDate1)*12+month(vDate1)+day(vDate1)/30

-  (year(vDate2)*12+month(vDate2)+day(vDate2)/30))

Now for this formula the results are wrong

=year(vDate1)*12+month(vDate1) -  (year(vDate2)*12+month(vDate2))

Clever_Anjos
Employee
Employee

Could you post a qvw? I´ll check this

jaimeaguilar
Partner - Specialist II
Partner - Specialist II

Hi,

Try

12*(Year(EndDate)-Year(StartDate))+(Month(EndDate)-Month(StartDate)) )

regards

marwen_garwachi
Creator II
Creator II
Author

That works Jaime Aguilar !! Thanks a lot .

Clever Anjos Thanks a lot too .