# Calculating the difference between two dates in terms of months

Hi Guys,

I need to create a calculated column for finding difference between two dates in terms of Month.

Could anyone help!!!

10|10000 characters needed characters exceeded

### Related questions

• Posted on Dec 04, 2018 at 09:14 AM
`select MONTHS_BETWEEN('20181001', '20181203') from dummy`
10|10000 characters needed characters exceeded
• Posted on May 31, 2019 at 12:42 PM

Sagarika, let us know in which sceneario it is not calculating as expected.

10|10000 characters needed characters exceeded
• Hi Hari,

Even i am facing same issue reported by Sagarika.

Failed Case is
select MONTHS_BETWEEN('20191031', '20191130') from dummy

This gives result as 0 but expected result is 1.

In ABAP we are able to achieve correct result via using Function Module - HR_AUPBS_MONTH_DAY

• Posted on May 31, 2019 at 02:02 PM

Hi Sagarika,

`SELECT DATEDIFF(MONTH, '2019-01-01', '2020-01-01') AS "Months Difference";`

Thank you,

Aziz

10|10000 characters needed characters exceeded
• Posted on Jun 11, 2019 at 01:40 PM

Hi,

What do you mean by in terms of months?

What if the dates are 1/1/2019 to 2/15/2019, what would be the result? Is it 1 or 2 months?

What if the dates are 1/31/2019 to 2/15/2019, what would be the result? Is it 1 or 2 months?

Then we can suggest how to solve your problem.

Do you base the "month" with 30 days or is it based on the number of months in your dates?

Regards,

Loed