Application Development and Automation Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 
Read only

Date manipulation

Former Member
0 Likes
658

I get a date from a char10 field as 12/12/2006

Now I need to find the difference in months between sy-datum and the date. How to accomplish this. Thank you

1 ACCEPTED SOLUTION
Read only

ferry_lianto
Active Contributor
0 Likes
530

Hi,

Please try FM MONTHS_BETWEEN_TWO_DATES.


DATA: DATE1(10) VALUE '12/12/2006',
      DATE2 TYPE SY-DATUM,
      MONTH TYPE I.
                                                                        
MOVE: DATE1+6(4) TO DATE2(4),
      DATE1+3(2) TO DATE2+4(2),
      DATE1+0(2) TO DATE2+6(2).
                                                                        
CALL FUNCTION 'MONTHS_BETWEEN_TWO_DATES'
  EXPORTING
    I_DATUM_BIS         = SY-DATUM
    I_DATUM_VON         = DATE2
  IMPORTING
    E_MONATE            = MONTH.
                                                                        
WRITE: / MONTH.

Regards,

Ferry Lianto

3 REPLIES 3
Read only

ferry_lianto
Active Contributor
0 Likes
531

Hi,

Please try FM MONTHS_BETWEEN_TWO_DATES.


DATA: DATE1(10) VALUE '12/12/2006',
      DATE2 TYPE SY-DATUM,
      MONTH TYPE I.
                                                                        
MOVE: DATE1+6(4) TO DATE2(4),
      DATE1+3(2) TO DATE2+4(2),
      DATE1+0(2) TO DATE2+6(2).
                                                                        
CALL FUNCTION 'MONTHS_BETWEEN_TWO_DATES'
  EXPORTING
    I_DATUM_BIS         = SY-DATUM
    I_DATUM_VON         = DATE2
  IMPORTING
    E_MONATE            = MONTH.
                                                                        
WRITE: / MONTH.

Regards,

Ferry Lianto

Read only

Former Member
0 Likes
530

Hi Megan,

Use the function module<b> MONTHS_BETWEEN_TWO_DATES </b>to get the number of days difference between days.

Change the character date 12/12/2006 to a date and give this value and the second value as sy-datum.

Thanks,

Vinay

Read only

Former Member
0 Likes
530

You can try other FM's if you need :

FIMA_DAYS_AND_MONTHS_AND_YEARS

MONTHS_BETWEEN_TWO_DATES_NEW

Thanks

Seshu