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

Announcements
Qlik Open Lakehouse is Now Generally Available! Discover the key highlights and partner resources here.
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 Ambassador/MVP
Partner Ambassador/MVP

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