08-29-2016 12:25 PM
Hi,
Is there any FM for finding the number of Saturday's between two dates.
Thanks,
Satish.
08-29-2016 1:21 PM
Hello,
DATE_TO_DAY says what day a date is. So you could loop over your period and count the saturdays.
Regards
08-29-2016 2:55 PM
Thanks Jan. I was searching for any standard FM from SAP as the requirement seems to be straight forward.
08-29-2016 3:55 PM
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..