Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 
kunkumnaveen
Specialist
Specialist

Count number of months between two dates

Hello all,

Need help in writing  a expression in a chart  ,which count the number of months b/w Date1 and Date2

 

Thanks

 

Labels (1)
1 Solution

Accepted Solutions
anushree1
Specialist II
Specialist II

Please try this:

((year(Date#('31-02-2019','DD-MM-YYYY'))*12)+month(Date#('31-02-2019','DD-MM-YYYY'))) - (((year(Date#('01-01-2018','DD-MM-YYYY'))*12)+month(Date#('01-01-2018','DD-MM-YYYY'))))

View solution in original post

5 Replies
anushree1
Specialist II
Specialist II

Try:   Month(Date#(End_date,'DD-MM-YYYY'))-Month(Date#(Start_date,'DD-MM-YYYY'))

kunkumnaveen
Specialist
Specialist
Author

Thanks Anushree,

some issue in the expression

Month(Date#('31-02-2019','DD-MM-YYYY'))-Month(Date#('01-01-2019','DD-MM-YYYY')) 

Count=2 which is right

Month(Date#('31-02-2019','DD-MM-YYYY'))-Month(Date#('01-01-2018','DD-MM-YYYY'))

Count =2  which is wrong suppose to be more than 2 

 

 

 

 

anushree1
Specialist II
Specialist II

Please try this:

((year(Date#('31-02-2019','DD-MM-YYYY'))*12)+month(Date#('31-02-2019','DD-MM-YYYY'))) - (((year(Date#('01-01-2018','DD-MM-YYYY'))*12)+month(Date#('01-01-2018','DD-MM-YYYY'))))

kunkumnaveen
Specialist
Specialist
Author

Thanks ,it worked ,can u plz help me in understanding ur expression ,y do we need multiple year with 12 

anushree1
Specialist II
Specialist II

Multiplying years from both From and End Date is essential to track the years in hand supposedly from and to both are same years you will see the difference in months in case they are different an additive 12  is required for the difference in months .

If its not clear just take 2 different years and do the math like 2000 - 02 Vs 2002 -05 so when i multiply 2 ;Month difference between 2 Years is 24 (2002 -2000->2 Yrs ->24 Months)+Difference in Months 5-2->3 

So now its 24+3=27

Hope this is clear