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 get no of sundays in a month of a year

former_member329859
Participant
0 Kudos

hello all experts,

please tell me how to calculate no of sundays in a month when i have month its start & end date & year

thanking you,

gaurav

1 ACCEPTED SOLUTION

GauthamV
Active Contributor
0 Kudos

hi,

use these fm.

DATE_COMPUTE_DAY

DAY_ATTRIBUTES_GET.

4 REPLIES 4

GauthamV
Active Contributor
0 Kudos

hi,

use these fm.

DATE_COMPUTE_DAY

DAY_ATTRIBUTES_GET.

karol_seman
Active Participant
0 Kudos

Hi Gaurav,

I don't know about FM which does this but the logic can be simple.

Loop all the days between your two dates and for each date just call FM DATE_COMPUTE_DAY which returns 7 if it is Sunday.

To increase the date please use FM CALCULATE_DATE.

Regards,

Karol

P.S.: If people answer your question please close the question as answered (It is not good to have all questions open if they are already answered ...)

Former Member
0 Kudos

try this:

data : lf_date type dats,

counter type i value 0.

select-options: so_date for lf_date default '20080901' to '20080920'.

data :working_days like standard table of RKE_DAT with header line.

data : days type i,

month type i,

year type i,

cal_days type i.

*Total no. of days b/w dates

CALL FUNCTION 'HR_AUPBS_MONTH_DAY'

EXPORTING

BEG_DA = so_date-low

END_DA = so_date-high

IMPORTING

NO_DAY = days

NO_MONTH = month

NO_YEAR = year

NO_CAL_DAY = cal_days

.

*Total no. of working days b/w dates

CALL FUNCTION 'RKE_SELECT_FACTDAYS_FOR_PERIOD'

EXPORTING

I_DATAB = so_date-low

I_DATBI = so_date-high

I_FACTID = 'ST'

TABLES

ETH_DATS = working_days

EXCEPTIONS

DATE_CONVERSION_ERROR = 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.

loop at working_days.

read table working_days.

counter = counter + 1.

endloop.

write:/ working_days-PERIODAT,

/ counter,

/ cal_days.

here 'ST' is the factoru calender.

hope this serves your purpose.

Sid

former_member705122
Active Contributor
0 Kudos

Hi,

Similar post:

->Get the number of sundays in a month,

Link:

Regards

Adil