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: 

Number of working days between two dates

Former Member
0 Kudos

Hi All,

How we can calculate no of working days between two dates,if working days are from monday to friday.

Thanks in advance.

Regards,

Sarala.

1 ACCEPTED SOLUTION

Former Member

Hi,

You can use the following FM

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

Regards,

Padmam.

9 REPLIES 9

Former Member
0 Kudos

hi..

FIMA_DAYS_AND_MONTHS_AND_YEARS

HR_SGPBS_YRS_MTHS_DAYS

RKE_SELECT_FACTDAYS_FOR_PERIOD

check these .

reward if useful

regards

ashu

Former Member
0 Kudos

Hi Sarala,

Try to use this FM

WEEK_GET_NR_OF_WORKDAYS

Reward if useful

Former Member

Hi,

You can use the following FM

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

Regards,

Padmam.

Former Member
0 Kudos

Hi,

parameters: p_start type sy-datum,

p_end type sy-datum.

data: idays type table of rke_dat with header line.

data: workingdays type i.

call function 'RKE_SELECT_FACTDAYS_FOR_PERIOD'

exporting

i_datab = p_start

i_datbi = p_end

i_factid = 'P8' " Fact Calender ID

tables

eth_dats = idays

exceptions

date_conversion_error = 1

others = 2.

describe table idays lines workingdays.

write:/ workingdays.

Thanks,

Former Member
0 Kudos

Hi,

You may use FM DAY_ATTRIBUTES_GET for the same.

Regards

Raju Chitale

Former Member
0 Kudos

Hi,

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

try like the below

1. Independent PERFORM

for this purpose.

2. Using FM and logic

below is a FORM

which independelty

gives the NUMBER OF WORKING DAys

(inputs are : fromdate, todate, days)

eg. From 24-jan-2006

25-jan-2006

26-jan-2006 (republic day in india)

27-jan-2006

It will Return 3

3. see this code (just copy paste)

REPORT abc.

*----


DATA : days TYPE i.

DATA : dt TYPE sy-datum.

*----


SELECT-OPTIONS : mydate FOR sy-datum DEFAULT '20060124' TO '20060127'.

*----


START-OF-SELECTION.

PERFORM calcdays USING mydate-low mydate-high days.

WRITE days .

*----


  • FORM

*----


FORM calcdays USING fromdate todate days.

DATA : dt TYPE sy-datum.

dt = fromdate.

DO.

IF dt > todate.

EXIT.

ENDIF.

CALL FUNCTION 'DATE_CHECK_WORKINGDAY'

EXPORTING

date = dt

factory_calendar_id = 'IN'

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.

dt = dt + 1.

IF sy-subrc = 0.

days = days + 1.

ENDIF.

ENDDO.

ENDFORM. "calcdays

Check the link answer given by rich

https://forums.sdn.sap.com/click.jspa?searchID=3460848&messageID=935342

<b>Reward points</b>

Regards

kostas_tsioubris
Contributor
0 Kudos

Hi,

check .

Kostas

Former Member
0 Kudos

Hi,

use the FM

K_ABC_WORKDAYS_FOR_PERIODS_GET

Regards,

Nandha

Former Member
0 Kudos

Thanks for all for your replies,my problem is solved.