‎2007 Sep 03 9:31 AM
Dear All,
I want to find the difference between two dates according to the factory calender.
For eg: 13.07.2007 - 04.07.2007 = 9 days
But in that 9 days there is one festival holiday and weekenend.So totally three days has to remove.So finally the difference between 13.07 and 14.07 is 6 days only according to the factory calender.
Please let me know how to get this.
‎2007 Sep 03 9:34 AM
Hi shoban babu
This is the FM that you can use to fine a date between period that you would like .
CALL FUNCTION 'RKE_SELECT_FACTDAYS_FOR_PERIOD'
EXPORTING
i_datab = p_start_date
i_datbi = p_end_date
i_factid = 'TH'
TABLES
eth_dats = it_rke_dat.
EXCEPTIONS
DATE_CONVERSION_ERROR = 1
OTHERS = 2
Regards
Wiboon
‎2007 Sep 03 9:33 AM
*For calculating days excluding weekends
CALL FUNCTION 'DAYS_BETWEEN_TWO_DATES'
EXPORTING
i_datum_bis = end_date
i_datum_von = start_date
IMPORTING
e_tage = l_diff_dates
EXCEPTIONS
days_method_not_defined = 1
OTHERS = 2.
IF sy-subrc <> 0.
MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
ENDIF.
IF NOT start_date IS INITIAL AND
NOT end_date IS INITIAL.
CALL FUNCTION 'CATSXT_GET_HOLIDAYS'
EXPORTING
im_personnel_number = '00000000'
im_begin_date = start_date
im_end_date = end_date
im_get_weekend_days = 'X'
IMPORTING
ex_holidays = i_holiday_tab.
DELETE i_holiday_tab WHERE freeday = ' '.
DESCRIBE TABLE i_holiday_tab LINES l_lines.
IF l_diff_dates NE 1.
l_diff_dates = l_diff_dates - l_lines.
ENDIF.
ENDIF.
‎2007 Sep 03 9:33 AM
Hi,
use the function module
HR_HK_DIFF_BT_2_DATES
and run this with the following values
DATE1 02.10.2007
DATE2 10.09.2007
OUTPUT_FORMAT 02
output will be like this
Export Parameters Value
YEARS 0,0000
MONTHS 0,0000
DAYS 23
if you change the output_format to 01
it will give in years
thanks & regards,
Venkatesh
‎2007 Sep 03 9:34 AM
Hi shoban babu
This is the FM that you can use to fine a date between period that you would like .
CALL FUNCTION 'RKE_SELECT_FACTDAYS_FOR_PERIOD'
EXPORTING
i_datab = p_start_date
i_datbi = p_end_date
i_factid = 'TH'
TABLES
eth_dats = it_rke_dat.
EXCEPTIONS
DATE_CONVERSION_ERROR = 1
OTHERS = 2
Regards
Wiboon
‎2007 Sep 03 9:36 AM
Hi shoban,
you may use function module DURATION_DETERMINE.
I hope this helps. Best regards,
Alvaro
‎2007 Sep 03 9:36 AM
shoban babu pointed the right FM... It just does the same as my pseudo-code would do.
-
-
If you cannot get a FM to do it, just make your own.
Call the function DATE_CONVERT_TO_FACTORYDATE from the lower date to the highest, adding one day to the next working day obtained.
date_ini = lower_date.
DO.
CALL FUNCTION 'DATE_CONVERT_TO_FACTORYDATE'
* parameters, yadda yadda
* EXPORTING new_date
IF new_date = higher_date.
EXIT.
ELSE.
ADD 1 TO diff.
ADD 1 TO date_ini.
ENDIF.
ENDDO.Message was edited by:
Vicenç Lozano
Who hates to duplicate answers because timing