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

dif between two dates

Former Member
0 Likes
761

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.

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
729

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

5 REPLIES 5
Read only

Former Member
0 Likes
729

*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.

Read only

Former Member
0 Likes
729

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

Read only

Former Member
0 Likes
730

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

Read only

Former Member
0 Likes
729

Hi shoban,

you may use function module DURATION_DETERMINE.

I hope this helps. Best regards,

Alvaro

Read only

VXLozano
Active Contributor
0 Likes
729

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