Skip to Content

Archived discussions are read-only. Learn more about SAP Q&A

Function for counting a sunday in a particular month

Dear all,

i have a date like 01.10.2008 & 31.10.2008.

now i want to count the number of sundays arrived in between this month.

Have any function???????????

plz help me.

Anshuman

Tags:
replied

try using this code

data: begdat type sydatum,
     enddat type sydatum,
     day type p,
     counter type i.
begdat = '20081001'.
enddat = '20081031'.
do.
  day = begdat mod 7.
  if day > 1.
     day = day - 1.
  else.
     day = day + 6.
  endif.
  if day = '6'.
    counter = counter + 1.
  endif.
  if begdat < enddat.
    begdat = begdat + 1.
  else.
    exit.
  endif.
enddo.
write: counter,'SUNDAYS'.

0 View this answer in context
Not what you were looking for? View more on this topic or Ask a question