Skip to Content
avatar image
Former Member

Function module to find the months between two different dates

Hi,

I have a requirement in which the client wants to change the product from existing one to new product(report)....and i have to check whether the client is changing the product before 12 months of the issue date of existing product.

How do i do this..is ther any function module to find the month between two different dates??

Add comment
10|10000 characters needed characters exceeded

  • Get RSS Feed

5 Answers

  • Best Answer
    avatar image
    Former Member
    Jan 21, 2008 at 07:07 AM

    Hi,

    Check the following code:

    REPORT ZDATEDIFF.

    DATA: EDAYS LIKE VTBBEWE-ATAGE,

    EMONTHS LIKE VTBBEWE-ATAGE,

    EYEARS LIKE VTBBEWE-ATAGE.

    PARAMETERS: FROMDATE LIKE VTBBEWE-DBERVON,

    TODATE LIKE VTBBEWE-DBERBIS DEFAULT SY-DATUM.

    call function 'FIMA_DAYS_AND_MONTHS_AND_YEARS'

    exporting

    i_date_from = FROMDATE

    i_date_to = TODATE

    • I_FLG_SEPARATE = ' '

    IMPORTING

    E_DAYS = EDAYS

    E_MONTHS = EMONTHS

    E_YEARS = EYEARS.

    WRITE:/ 'Difference in Days ', EDAYS.

    WRITE:/ 'Difference in Months ', EMONTHS.

    WRITE:/ 'Difference in Years ', EYEARS.

    INITIALIZATION.

    FROMDATE = SY-DATUM - 60.

    Regards,

    Bhaskar

    Add comment
    10|10000 characters needed characters exceeded

  • avatar image
    Former Member
    Jan 21, 2008 at 07:08 AM

    Check this FM MONTHS_BETWEEN_TWO_DATES

    Add comment
    10|10000 characters needed characters exceeded

  • avatar image
    Former Member
    Jan 21, 2008 at 07:09 AM

    FM: HR_AUPBS_MONTH_DAY

    This FM will return you number of Years, Months and Days between Begin date and endDate.

    Add comment
    10|10000 characters needed characters exceeded

  • avatar image
    Former Member
    Jan 21, 2008 at 07:11 AM

    Hi Sudheer,

    Have a look at the following link.

    http://abapcode.blogspot.com/2008/01/sap-function-module-for-date-and-time.html

    Regards,

    Kinshuk

    Add comment
    10|10000 characters needed characters exceeded

  • avatar image
    Former Member
    Jan 21, 2008 at 07:14 AM

    Hi,

    Use the FM, 'HR_HK_DIFF_BT_2_DATES' to find the number of months exists between the given 2 dates.

    See the following example...

    Data: d1 type sy-datum,

    d2 type sy-datum,

    wf_month_diff type P0347-SCRMM.

    call function 'HR_HK_DIFF_BT_2_DATES'

    exporting

    date1 = d1

    date2 = d2

    output_format = '04'

    importing

    months = wf_month_diff.

    • In the 'wf_month_diff' variable, you will get the month difference between these two dates.

    Regards,

    Shanthi.P

    • Reward points if useful *****

    Add comment
    10|10000 characters needed characters exceeded