‎2008 Aug 14 10:37 AM
I need a function module which can find out the weekends in between 2 dates. I need this to count the days between the two given dates excluding the weekends.
‎2008 Aug 14 10:40 AM
Hi,
Check the following functional modules.
HR_99S_INTERVAL_BETWEEN_DATES : Difference between two dates in days, weeks, months
WEEK_GET_FIRST_DAY : Get the first day of the week
FIMA_DAYS_AND_MONTHS_AND_YEARS : Find the difference between two dates in years, months and days.
DATE_TO_DAY : Returns the Day for the entered date.
Hope it is helps,,,
Regards,
T.D.M.
‎2008 Aug 14 10:43 AM
by weekend do you mean u want to exclude 1 weekend or 2 days of a weekend.....
get day of week number for date using following logic...(the FM is /ITSAM/HC_DATE_TO_WEEK but if you don't have it..here is the code)
DATA l_year TYPE i.
DATA l_month TYPE i.
DATA l_day TYPE i.
DATA l_day_of_week TYPE i.
DATA l_temp TYPE f.
l_year = i_date(4).
l_month = i_date+4(2).
l_day = i_date+6(2).
IF l_month < 3.
l_year = l_year - 1.
l_month = l_month + 12.
ENDIF.
l_day_of_week = l_day.
l_temp = 153 * l_month - 457.
l_day_of_week = l_day_of_week + ( l_temp ) DIV 5.
l_temp = '365.25' * l_year.
l_day_of_week = l_day_of_week + FLOOR( l_temp ).
l_temp = l_year * '0.01'.
l_day_of_week = l_day_of_week - FLOOR( l_temp ).
l_temp = l_year * '0.0025'.
l_day_of_week = l_day_of_week + FLOOR( l_temp ).
l_day_of_week = l_day_of_week + 2.
l_day_of_week = l_day_of_week MOD 7.
IF l_day_of_week < 0.
l_day_of_week = l_day_of_week + 7.
ENDIF.
e_day_of_week = l_day_of_week.
here i_date is the input date and e_day_of_week is the number for weekday (eg monday will be 1)
after getting this number....get weekday names with numbers using WEEKDAY_GET function module...
here you can find that against 1, there will be monday , 2-tuesday and so on..
you can use this logic to go further