Application Development 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: 

FM for finding number of Saturday between two dates

satish_rajamanickam
Participant
0 Kudos

Hi,

Is there any FM for finding the number of Saturday's between two dates.

Thanks,

Satish.

3 REPLIES 3

JanSchlichting
Active Participant
0 Kudos

Hello,

DATE_TO_DAY says what day a date is. So you could loop over your period and count the saturdays.

Regards

0 Kudos

Thanks Jan. I was searching for any standard FM from SAP as the requirement seems to be straight forward.

former_member185116
Active Participant
0 Kudos

hi satish,

i don't think there is any direct FM to compute no of saturdays,

please check below code,

DATA: lv_date1 TYPE dats VALUE '20160820',
       lv_date2 TYPE dats VALUE '20160829',
       lv_div TYPE i,
       lv_mod TYPE i,
       lv_diff TYPE i,
       lv_count TYPE i,
       lv_day TYPE SCAL-INDICATOR.


lv_diff = lv_date2 - lv_date1.


lv_div = lv_diff DIV 7.
lv_mod = lv_diff MOD 7.

lv_count = lv_div.

CALL FUNCTION 'DATE_COMPUTE_DAY'
   EXPORTING
     date = lv_date1
   IMPORTING
     day  = lv_day.

lv_mod = lv_mod + lv_day.

IF lv_mod GE 7.
   ADD 1 TO lv_count.
ENDIF.

WRITE : / 'No of Saturdays = ' , lv_count.

hope its should be helpful,

regards,

vinay..