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: 

For a given date required last week day

Former Member
0 Kudos

Hi Friends,

Is there any function module exists if I will enter any date as input parameter

the last thursday date should come as output ?

For example 1: The input parameter is 15.04.2009 (15th is Wednesday) so the output is 09.04.2009(bcz last thrusday is 9th)

2. Suppose if the input parameter is 17.04.2009 (17th is friday) so the output is 16.04.2009(bcz last thrusday is 16th)

Thanks

Raj

2 REPLIES 2

Former Member
0 Kudos

Hi ,

You can use the following code:


data : v_date type datum,
         v_day(10) type c.
v_date = pass whatever date you want in format yyyymmdd .

do .

CALL FUNCTION 'DATE_TO_DAY'
  EXPORTING
    date          = v_date
 IMPORTING
   WEEKDAY       = v_day

if  v_day <> 'Thursday'.
 v_date = v_date - 1 .
else.
  write:  v_date .
 exit.
endif.
enddo.

Regardrs,

Ashish Arora

amit_khare
Active Contributor
0 Kudos

Welcome to SCN.

Please search the forum for the query before posting it.

Just a hint as this is your first post...

use the fm DAY_IN_WEEK, it return the number of the day of the week

1 (Monday) & 7 (Sunday)

now do some calculation to get thursday...