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 Calculation

Former Member
0 Likes
552

Can somebody tell me as to how number of days can be calculated between given two dates??

I want the number of days , like between 20/04/2007 and 25/04/2007 the number of days are 6 days.

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
529

Hi

simply use substraction

declare days as Type I.

days = date1 - date2.

reward points

regards

Anji

5 REPLIES 5
Read only

Former Member
0 Likes
530

Hi

simply use substraction

declare days as Type I.

days = date1 - date2.

reward points

regards

Anji

Read only

Former Member
0 Likes
529

I think just subtract the two and put the result in a integer field should do the trick !!

Read only

alex_m
Active Contributor
0 Likes
529

Data day type i.

day = date1 - date2.

Read only

ferry_lianto
Active Contributor
0 Likes
529

Hi,

Please use FM HR_HK_DIFF_BT_2_DATES.



DATA: L_DATE1 LIKE SY-DATUM VALUE '20040425',
      L_DATE2 LIKE SY-DATUM VALUE '20040420',
      L_DAYS  LIKE P0347-SCRDD.
                                                                        
CALL FUNCTION 'HR_HK_DIFF_BT_2_DATES'
  EXPORTING
    DATE1                   = L_DATE1
    DATE2                   = L_DATE2
    OUTPUT_FORMAT           = '03'
  IMPORTING
    DAYS                    = L_DAYS
  EXCEPTIONS
    INVALID_DATES_SPECIFIED = 1
    OTHERS                  = 2.
                                                                        
WRITE: / L_DAYS.

Regards,

Ferry Lianto

Read only

Former Member
0 Likes
529

data: days type i.

days = day_l - day_s.