04-17-2006 7:04 AM
Hi all,
Is there any date function module to find out the date on last friday....
And one more thing....any function module to findout the range of dates for the last week...(i.e) date from last week monday to last week friday.
Thanking u all in advance.
Regards,
Chandra Sekhar
04-17-2006 7:36 AM
REPORT ZSN_FRIDAYTEST .
data: days type p.
data: date type sy-datum.
parameters: p_date like sy-datum default sy-datum.
*-- Get the last Friday
call function 'DAY_IN_WEEK'
exporting
datum = p_date
IMPORTING
WOTNR = days.
days = days + 2.
date = p_date - days.
write:/ '(Assuming Monday is the first day of the week)'.
write:/ 'Date Entered:', p_date.
write:/ 'Last Friday:', date.
*- Range of dates in last week
data: date1 type sy-datum.
data: date2 type sy-datum.
data: days1 type p.
data: days2 type p.
call function 'BWSO_DATE_GET_FIRST_WEEKDAY'
exporting
date_in = p_date
IMPORTING
DATE_OUT = date1
.
date1 = date1 - 7.
date2 = date1 + 4.
write:/ 'Range:', date1, '-', date2.
04-17-2006 7:40 AM
Hi
<b>DATE_COMPUTE_DAY</b>---> Returns day of the week for a particular date(1=Monday, 5=Friday etc.)
you can use this Functio module, if you execute this on monday, then it will give you the result as <b>'1'</b>, so by this one, you can that this is monday, so just decrease it by 2 days, i mean decrease the SY-DATUM , you will find the last friday date.
think it about the FM, and the result of the FM, you will solve your Problem
Thanks
Sudheer
04-17-2006 7:45 AM
Thank you guys....
I had the same idea...but i was looking for a standard fm to get that date on last friday...I searched for it & didn't find any...
Thanks for ur time...
Regards,
Chandru
04-17-2006 7:47 AM
Hi Sekhar,
u can use FM RH_GET_DATE_DAYNAME. input the last date of the month n get the day for that. n u can subtract the appropriate no. of days from this to get the date on last friday.
eg if 31.03.2006 gives saturday
subtract 1 for this to get 30.03.2006 as friday & so on.
similarly u can use this for ur 2nd query too.
Regards,
Bikash