Skip to Content

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!!!

Add a comment
10|10000 characters needed characters exceeded

Related questions

4 Answers

  • Posted on Dec 04, 2018 at 09:14 AM
    select MONTHS_BETWEEN('20181001', '20181203') from dummy
    Add a comment
    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.

    Add a comment
    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,

    Please try this:

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

    Thank you,

    Aziz

    Add a comment
    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

    Add a comment
    10|10000 characters needed characters exceeded

Before answering

You should only submit an answer when you are proposing a solution to the poster's problem. If you want the poster to clarify the question or provide more information, please leave a comment instead, requesting additional details. When answering, please include specifics, such as step-by-step instructions, context for the solution, and links to useful resources. Also, please make sure that you answer complies with our Rules of Engagement.
You must be Logged in to submit an answer.

Up to 10 attachments (including images) can be used with a maximum of 1.0 MB each and 10.5 MB total.