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: 

FM to get Number of wednesday in a month

Former Member
0 Kudos

Hi ,

I have a requirement where I have to fetch number of Wednesdays in a month .

Can anyone help me as to how can i do that ?

EX .

We have

5 Wednesdays in April.2009

4 in May 2009 .

and so on.

1 ACCEPTED SOLUTION

babu_kilari4
Active Contributor
0 Kudos

Juhi,

Alternatively you can use the following FMs and count it by looping for a month.

DATE_TO_DAY

RH_GET_DATE_DAYNAME

ISP_GET_WEEKDAY_NAME

DATE_COMPUTE_DAY

Hope the above information will help you

Thanks,

Babu Kilari

6 REPLIES 6

Former Member
0 Kudos

hi:

The function module DATE_TO_DAY give the day of the date. for days count, if you have to put the logic like

if 01-04-2009 (d1) : days wednesday then

08-04-2009 (d2 = d1+7) = wednesday

15-04-2009 (d3= d2+7) = wednesday

22-04-2009 (d4 =d3+7) = wednesday

29-04-2009 (d5 =d4+7) = wednesday

The first required day you should find then add like above till the month end.

Regards

Shashi

Former Member
0 Kudos

Hi,

The solution to your query would be run a loop starting with the 1st date of the month till the last date.

Call any of the FMs:

DATE_COMPUTE_DAY - This determines the day of the week for a date

DAY_IN_WEEK - This returns the day of the week for a date

When the FM returns a day, keep a check on if its wednesday, keep count and you will get your result.

Get back to me if you face any difficulties.

Regards.

babu_kilari4
Active Contributor
0 Kudos

Juhi,

Check this out

DATA : lv_start TYPE sy-datum VALUE '20080714',

lv_end TYPE sy-datum VALUE '20080814'.

WHILE lv_start LE lv_end.

CALL FUNCTION 'FTR_DAY_GET_TEXT'

EXPORTING

pi_date = lv_start.

  • IMPORTING

  • PE_DAY_TEXT1 =

  • PE_DAY_TEXT2 =

  • PE_DAY =

.

  • you have to summarize the output here somehow...

lv_start = lv_start + 1.

ENDWHILE.

babu_kilari4
Active Contributor
0 Kudos

Juhi,

Alternatively you can use the following FMs and count it by looping for a month.

DATE_TO_DAY

RH_GET_DATE_DAYNAME

ISP_GET_WEEKDAY_NAME

DATE_COMPUTE_DAY

Hope the above information will help you

Thanks,

Babu Kilari

Former Member
0 Kudos

Hi Juhi,

Are u still watching this thread? If you have got your answer please mark this thread as 'Answered'.

Regards.

Former Member
0 Kudos

Thank you for your time and answers