‎2006 Aug 21 10:02 AM
hi all,
i want to retrieve difference between two dates in working hours(excluding holidays and weekends as per US calender).
Could u please help?
Regards,
‎2006 Aug 21 10:04 AM
‎2006 Aug 21 10:06 AM
‎2006 Aug 21 10:07 AM
hi prashant,
but i want the difference excluding holidays and weekends. SD_DATETIME_DIFFERENCE will not do that.
‎2006 Aug 21 10:07 AM
hi prashant,
thanks.
but i want the difference excluding holidays and weekends. SD_DATETIME_DIFFERENCE will not do that.
‎2006 Aug 21 10:10 AM
Hi abhijeet,
(This will exclude weekends)
1. DATE_CHECK_WORKINGDAY
This is one useful FM
2. Try this code (just copy paste)
IT DOES EXACTLY WHAT U REQUIRE.
REPORT abc.
data : num type i.
parameters : frdate type sy-datum default '20051216'.
parameters : todate type sy-datum default '20051221'.
perform getinfo using frdate todate changing num.
break-point.
&----
*& Form getinfo
&----
text
----
FORM getinfo USING fromdate todate CHANGING numofdays type i.
DATA : d TYPE sy-datum.
d = fromdate - 1.
DO.
d = d + 1.
IF d > todate.
EXIT.
endif.
CALL FUNCTION 'DATE_CHECK_WORKINGDAY'
EXPORTING
date = d
factory_calendar_id = '01'
message_type = 'I'
EXCEPTIONS
date_after_range = 1
date_before_range = 2
date_invalid = 3
date_no_workingday = 4
factory_calendar_not_found = 5
message_type_invalid = 6
OTHERS = 7.
IF sy-subrc = 0.
numofdays = numofdays + 1.
write 😕 d.
ENDIF.
ENDDO.
ENDFORM. "getinfo
I hope it helps.
Regards,
Amit M.
‎2006 Aug 21 10:17 AM
I am not sure of any specific function for the same but you can use the below logic.
ldat1 = first date
ldat2 = second date.
ldat = ldat1 - 1.
do while ldat <= ldat2.
ldat = ldat + 1.
check holiday.
check Sat or Sunday using SY-FDAYW.
lday = lday + 1.
enddo.
lhrs = lday * 24.
Regards
Anurag
‎2006 Aug 21 10:21 AM
Hi Abhijeet,
Check FM's RKE_SELECT_FACTDAYS_FOR_PERIOD, FIMA_DAYS_AND_MONTHS_AND_YEARS and
HR_HK_DIFF_BT_2_DATES
Hope this helps
Thanks
Lakshman