Skip to main content
Announcements
Introducing Qlik Answers: A plug-and-play, Generative AI powered RAG solution. READ ALL ABOUT IT!
cancel
Showing results for 
Search instead for 
Did you mean: 
Manel222
Contributor II
Contributor II

Number of months between two dates

Hello Guys,

I need to calulate the number of mothes between 2 variables start date and end date

I tried this but didn't work, any help please ?

LET vNbMois = (Year(Date#($(vDateFin), 'DD/MM/YYYY')) - Year(Date#($(vDateDebut), 'DD/MM/YYYY'))) * 12 + (Month(Date#($(vDateFin), 'DD/MM/YYYY')) - Month(Date#($(vDateDebut), 'DD/MM/YYYY')));

 

 

Labels (5)
1 Reply
igoralcantara
Partner - Specialist
Partner - Specialist

The formula I recommend is the following formula. Is that doesn't work, it could be the date format you proving as an input. Try, for example, to place the variables in your formula in single quotes. If still does not work, let us know what value you are getting in result and what is the value of each one of your variables.

Month(Date2) - Month(Date1) + 12 * (Year(Date2) - Year(Date1)) 

Check out my latest posts at datavoyagers.net