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: 

How to calculate working days between two dates.

Former Member
0 Kudos

Hi experts,

How to calculate working days between two dates? Is there any FM for it?

Points will be rewarded.

Thx in advance.

Vincent

1 ACCEPTED SOLUTION

Former Member
0 Kudos

Hi vincent,

1. Not only the number of days,

but also the list of dates.

WORKING DAYS based upon the calendar id.

2. This program

(it has an independent form)

which will give such thing.

3. Just copy paste in new program.

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

regards,

amit m.

3 REPLIES 3

Former Member
0 Kudos

Hello,

Check thnese FM's :-

FIMA_DAYS_AND_MONTHS_AND_YEARS

HR_SGPBS_YRS_MTHS_DAYS

RKE_SELECT_FACTDAYS_FOR_PERIOD

CALL FUNCTION 'RKE_SELECT_FACTDAYS_FOR_PERIOD'

EXPORTING

i_datab = date1

i_datbi = date2

i_factid = 'GB'

TABLES

eth_dats = l_it_dat.

In i_factid you have to pass factory Id like for india 'IN' or some other coutnry

n pass two dates you will get only working days in between those two dates

according to that calender

Use the function module

WDKAL_DATE_ADD_FKDAYS

to get the No of working days between the date range.

and the function module,

WEEK_GET_NR_OF_WORKDAYS

K_ABC_WORKDAYS_FOR_PERIODS_GET

Regards,

Deepu.K

Former Member
0 Kudos

Hi vincent,

1. Not only the number of days,

but also the list of dates.

WORKING DAYS based upon the calendar id.

2. This program

(it has an independent form)

which will give such thing.

3. Just copy paste in new program.

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

regards,

amit m.

Former Member
0 Kudos

Hi,

Try functions,

=> DATE_CONVERT_TO_FACTORYDATE

=> HR_HK_DIFF_BT_2_DATES

Regards,

Bhaskar