Skip to main content
Announcements
Join us at Qlik Connect for 3 magical days of learning, networking,and inspiration! REGISTER TODAY and save!
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

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