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

Announcements
Join us to spark ideas for how to put the latest capabilities into action. Register here!
cancel
Showing results for 
Search instead for 
Did you mean: 
wanyunyang
Creator III
Creator III

get month

If I have two dates 02/21/2017 & 01/26/2018, how could I get the number of months between these two dates?

1 Solution

Accepted Solutions
jonathandienst
Partner - Champion III
Partner - Champion III

I prefer to define a MonthSequence field in my master calendar.

     ...

     Year(calDate) * 12 + Month(calDate) as MonthSequence,

     ...

In that case difference in months is simply the difference of the two month sequences.

If you want to do this in an expression, then you can do something similar

    =(Year(date1) * 12 + Month(date1)) - (Year(date2) * 12 + Month(date2))

Logic will get you from a to b. Imagination will take you everywhere. - A Einstein

View solution in original post

4 Replies
adityaakshaya
Creator III
Creator III

Hi Wanyun,

You can use below expression to get number of months between these two dates.

=Round((date#(01/26/2018) - date#(02/21/2017))/30,0)

Regards,

Akshaya

PS - if you find this as correct/helpful, mark it as Correct/Helpful.

Thiago_Justen_

May be:

Interval(End_Date-Start_Date,'MM')

Thiago Justen Teixeira Gonçalves
Farol BI
WhatsApp: 24 98152-1675
Skype: justen.thiago
sumanta12
Creator II
Creator II

FLOOR(INTERVAL(DATE(DATE#('01/26/2018','MM/DD/YYYY'),'DD/MM/YYYY')-DATE(DATE#('02/21/2017','MM/DD/YYYY'),'DD/MM/YYYY'),'D hh:mm')/30)

jonathandienst
Partner - Champion III
Partner - Champion III

I prefer to define a MonthSequence field in my master calendar.

     ...

     Year(calDate) * 12 + Month(calDate) as MonthSequence,

     ...

In that case difference in months is simply the difference of the two month sequences.

If you want to do this in an expression, then you can do something similar

    =(Year(date1) * 12 + Month(date1)) - (Year(date2) * 12 + Month(date2))

Logic will get you from a to b. Imagination will take you everywhere. - A Einstein