Fucntion to Calculate business days (exclude weekends & holidays) between two days

Hello,
I need to be able to calculate business days between two dates excluding weekends and holidays. I do have a date dimension and also flags which denote weekday, holiday. Would really appreciate help in building a udf for the business days calculation.
Thanks,

Hi, Please take a look and tweak accordingly. Best of luck.
--Assuming data dimension table something like the following
--tblDateDim (DT date primary key,
flagHoliday bit,
flagWeekday bit
CREATE FUNCTION fnBusinessDays (
@StartDate DATE,
@EndDate DATE
RETURNS INT
AS
BEGIN
DECLARE @Days INT ;
SELECT @Days = count(*)
FROM tblDateDim --// date dimension
WHERE
( DT BETWEEN @StartDate AND @EndDate) --// dt is date column in the table.
AND --// also flags which denote weekday, holiday
flagHoliday = 0 --// flagHoliday= 1--Holiday;= 0 --workingday/businessday
AND
flagWeekday = 1 --// FlagWeekday = 1--businessday ; =0 --weekend (Saturday and Sunday)
RETURN (@Days)
END
GO

Similar Messages

  • How to find out public holiday between two days.

    Can any one let me know FM to find out public holiday between two days.
    for example: i am entering two days as 10-08-2009 to 20-08-2009. We have 15-08-2009 is a holiday. FM should say that 15th August is the public holiday.
    Regards,
    Manoj.

    hi,
    you can use HOLIDAY_CALENDAR_GET FM to get the holiday calendar id .
    Then pass that calender id and date to FM HOLIDAY_CHECK_AND_GET_INFO.
    Rgds.,
    subash

  • ICal custom repeat every x days EXCLUDING weekends?

    I have an event I would like to repeat every x number of days excluding weekends (so only counting M-F as "counted" days). Is there a way to do this?

    You can exclude Sat/Sun, but they will still be counted - so an occurrence on those days is dropped, and you will get fewer occurrences than you should.
    AK

  • How to Calculate the Time Between two days in ABAP

    Hi,
                  I have one scenario like i need to calculate the time between two days please can you suggest me.
    Thanks,
    Harinath

    Hi Peeleti,
                Check this code,
    DATA : DATE1 LIKE SY-DATUM VALUE '19830125',
           DATE2 LIKE SY-DATUM VALUE '20070219',
           DAYS1 TYPE I,
           WEEK1 TYPE I,
           MONTH1 TYPE I,
           YEAR1 TYPE I,
           C_YEARS1 TYPE I.
    CALL FUNCTION 'HR_99S_INTERVAL_BETWEEN_DATES'
    EXPORTING
      BEGDA           = DATE1
       endda           = DATE2
      TAB_MODE        = ' '
    IMPORTING
      DAYS            = DAYS1
      C_WEEKS         =
      C_MONTHS        = C_YEARS1
      C_YEARS         = C_YEARS1
      WEEKS           = WEEK1
      MONTHS          = MONTH1
      YEARS           = YEAR1.
      D_MONTHS        =
      MONTH_TAB       =
    *WRITE : / 'DAYS   = ', DAYS1,
            / 'WEEKS = ',WEEK1,
          /  'MONTHS = ', MONTH1,
          / 'YEARS   = ', YEAR1.
    Using this code you can calculate the No Of Days Between two dates. Based On days you will easily calculate the Hour. [  No of days * 24 ].
    Thanks.
    Reward If helpful.

  • Differnce between two days

    Hi All,
    I want function module to get difference between two days. (billing date and delivery date).
    So,can you help me out.
    Regards,
    Priya.

    Hi
    HR_HK_DIFF_BT_2_DATES : Find the difference between two dates in years, months and days.
    FIMA_DAYS_AND_MONTHS_AND_YEARS : Find the difference between two dates in years, months and days.
    Also go through the link given below :
    http://www.saptechies.com/abap-function-modules/
    With Regards
    Nikunj shah

  • Recursive CTE to get first business day excluding public holidays

    I wanted to write a recursive CTE to calculate the first business day excluding the public holidays for a given year. I have a table with the public holiday for that same year

    I like the functions I built to get this done:
    create function NthDayOfMonth (@year int, @month smallint, @weekday varchar(15), @nth smallint)
    returns datetime
    as
    begin
    declare @the_date datetime, @c_date datetime, @cth smallint
    set @cth = 0
    set @c_date = convert(varchar,@year)+'-'+convert(varchar,@month)+'-01'
    while month(@c_date) = @month
    begin
    if datename(weekday,@c_date) = @weekday set @cth = @cth + 1
    if @cth = @nth and datename(weekday,@c_date) = @weekday set @the_date = @c_date
    set @c_date = dateadd(day,1,@c_date)
    end
    return @the_date
    end
    GO
    create function Holidays(@year int)
    returns @table table
    date date,
    type varchar(10),
    name varchar(25)
    as
    begin
    insert into @table
    select convert(datetime,convert(varchar,@year)+'-01-01') as date,'Holiday' as type ,'New Years Day' as name UNION ALL
    select dbo.NthDayOfMonth(@year,2, 'Monday',3),'Holiday','Family Day' UNION ALL
    select dateadd(d,0-case when datepart(weekday,convert(varchar,@year)+'-05-25') in (1,2) then 5+datepart(weekday,convert(varchar,@year)+'-05-25') else datepart(weekday,convert(varchar,@year)+'-05-25')-1 end, convert(varchar,@year)+'-05-25') ,'Holiday','Victoria Day' UNION ALL
    select convert(varchar,@year)+'-07-01' ,'Holiday','Canada Day' UNION ALL
    select dbo.NthDayOfMonth(@year,8, 'Monday',1),'Holiday','Civic Holiday' UNION ALL
    select dbo.NthDayOfMonth(@year,9, 'Monday',1),'Holiday','Labour Day' UNION ALL
    select dbo.NthDayofMonth(@year,10,'Monday',2),'Holiday','Thanksgiving' UNION ALL
    select convert(varchar,@year)+'-11-11' ,'Holiday','Rememberance Day'UNION ALL
    select convert(varchar,@year)+'-12-25' ,'Holiday','Christmas Day' UNION ALL
    select convert(varchar,@year)+'-12-26' ,'Holiday','Boxing Day' UNION ALL
    SELECT CONVERT(DATE,CONVERT(VARCHAR,@year) + '-0'+CONVERT(VARCHAR, FLOOR((((( (19 * (@year % 19.0)) + FLOOR(@year / 100.0)) - FLOOR((@year / 100.0) / 4) - FLOOR((8 * (@year / 100.0) + 13) / 25.0) + 15) % 30) - (FLOOR((@year % 19.0 + (11 * ((( (19 * (@year % 19.0)) + FLOOR(@year / 100.0)) - FLOOR((@year / 100.0) / 4) - FLOOR((8 * (@year / 100.0) + 13) / 25.0) + 15) % 30))) / 319)) + ((((2 * FLOOR((@year / 100.0)) % 4) + (2*((@year % 100) / 4))) - ((@year % 100) % 4) - ((( (19 * (@year % 19.0)) + FLOOR(@year / 100.0)) - FLOOR((@year / 100.0) / 4) - FLOOR((8 * (@year / 100.0) + 13) / 25.0) + 15) % 30) + (FLOOR((@year % 19.0 + (11 * ((( (19 * (@year % 19.0)) + FLOOR(@year / 100.0)) - FLOOR((@year / 100.0) / 4) - FLOOR((8 * (@year / 100.0) + 13) / 25.0) + 15) % 30))) / 319)) +32) % 7) + 90) / 25))+'-'+CONVERT(VARCHAR,CONVERT(INT,(((( (19 * (@year % 19.0)) + FLOOR(@year / 100.0)) - FLOOR((@year / 100.0) / 4) - FLOOR((8 * (@year / 100.0) + 13) / 25.0) + 15) % 30) - (FLOOR((@year % 19.0 + (11 * ((( (19 * (@year % 19.0)) + FLOOR(@year / 100.0)) - FLOOR((@year / 100.0) / 4) - FLOOR((8 * (@year / 100.0) + 13) / 25.0) + 15) % 30))) / 319)) + ((((2 * FLOOR((@year / 100.0)) % 4) + (2*((@year % 100) / 4))) - ((@year % 100) % 4) - ((( (19 * (@year % 19.0)) + FLOOR(@year / 100.0)) - FLOOR((@year / 100.0) / 4) - FLOOR((8 * (@year / 100.0) + 13) / 25.0) + 15) % 30) + (FLOOR((@year % 19.0 + (11 * ((( (19 * (@year % 19.0)) + FLOOR(@year / 100.0)) - FLOOR((@year / 100.0) / 4) - FLOOR((8 * (@year / 100.0) + 13) / 25.0) + 15) % 30))) / 319)) +32) % 7) + (FLOOR((((( (19 * (@year % 19.0)) + FLOOR(@year / 100.0)) - FLOOR((@year / 100.0) / 4) - FLOOR((8 * (@year / 100.0) + 13) / 25.0) + 15) % 30) - (FLOOR((@year % 19.0 + (11 * ((( (19 * (@year % 19.0)) + FLOOR(@year / 100.0)) - FLOOR((@year / 100.0) / 4) - FLOOR((8 * (@year / 100.0) + 13) / 25.0) + 15) % 30))) / 319)) + ((((2 * FLOOR((@year / 100.0)) % 4) + (2*((@year % 100) / 4))) - ((@year % 100) % 4) - ((( (19 * (@year % 19.0)) + FLOOR(@year / 100.0)) - FLOOR((@year / 100.0) / 4) - FLOOR((8 * (@year / 100.0) + 13) / 25.0) + 15) % 30) + (FLOOR((@year % 19.0 + (11 * ((( (19 * (@year % 19.0)) + FLOOR(@year / 100.0)) - FLOOR((@year / 100.0) / 4) - FLOOR((8 * (@year / 100.0) + 13) / 25.0) + 15) % 30))) / 319)) +32) % 7) + 90) / 25)) + 19) % 32,0))),'Holiday','Easter Sunday' UNION ALL
    SELECT DATEADD(DAY,-2,CONVERT(DATE,CONVERT(VARCHAR,@year) + '-0'+CONVERT(VARCHAR, FLOOR((((( (19 * (@year % 19.0)) + FLOOR(@year / 100.0)) - FLOOR((@year / 100.0) / 4) - FLOOR((8 * (@year / 100.0) + 13) / 25.0) + 15) % 30) - (FLOOR((@year % 19.0 + (11 * ((( (19 * (@year % 19.0)) + FLOOR(@year / 100.0)) - FLOOR((@year / 100.0) / 4) - FLOOR((8 * (@year / 100.0) + 13) / 25.0) + 15) % 30))) / 319)) + ((((2 * FLOOR((@year / 100.0)) % 4) + (2*((@year % 100) / 4))) - ((@year % 100) % 4) - ((( (19 * (@year % 19.0)) + FLOOR(@year / 100.0)) - FLOOR((@year / 100.0) / 4) - FLOOR((8 * (@year / 100.0) + 13) / 25.0) + 15) % 30) + (FLOOR((@year % 19.0 + (11 * ((( (19 * (@year % 19.0)) + FLOOR(@year / 100.0)) - FLOOR((@year / 100.0) / 4) - FLOOR((8 * (@year / 100.0) + 13) / 25.0) + 15) % 30))) / 319)) +32) % 7) + 90) / 25))+'-'+CONVERT(VARCHAR,CONVERT(INT,(((( (19 * (@year % 19.0)) + FLOOR(@year / 100.0)) - FLOOR((@year / 100.0) / 4) - FLOOR((8 * (@year / 100.0) + 13) / 25.0) + 15) % 30) - (FLOOR((@year % 19.0 + (11 * ((( (19 * (@year % 19.0)) + FLOOR(@year / 100.0)) - FLOOR((@year / 100.0) / 4) - FLOOR((8 * (@year / 100.0) + 13) / 25.0) + 15) % 30))) / 319)) + ((((2 * FLOOR((@year / 100.0)) % 4) + (2*((@year % 100) / 4))) - ((@year % 100) % 4) - ((( (19 * (@year % 19.0)) + FLOOR(@year / 100.0)) - FLOOR((@year / 100.0) / 4) - FLOOR((8 * (@year / 100.0) + 13) / 25.0) + 15) % 30) + (FLOOR((@year % 19.0 + (11 * ((( (19 * (@year % 19.0)) + FLOOR(@year / 100.0)) - FLOOR((@year / 100.0) / 4) - FLOOR((8 * (@year / 100.0) + 13) / 25.0) + 15) % 30))) / 319)) +32) % 7) + (FLOOR((((( (19 * (@year % 19.0)) + FLOOR(@year / 100.0)) - FLOOR((@year / 100.0) / 4) - FLOOR((8 * (@year / 100.0) + 13) / 25.0) + 15) % 30) - (FLOOR((@year % 19.0 + (11 * ((( (19 * (@year % 19.0)) + FLOOR(@year / 100.0)) - FLOOR((@year / 100.0) / 4) - FLOOR((8 * (@year / 100.0) + 13) / 25.0) + 15) % 30))) / 319)) + ((((2 * FLOOR((@year / 100.0)) % 4) + (2*((@year % 100) / 4))) - ((@year % 100) % 4) - ((( (19 * (@year % 19.0)) + FLOOR(@year / 100.0)) - FLOOR((@year / 100.0) / 4) - FLOOR((8 * (@year / 100.0) + 13) / 25.0) + 15) % 30) + (FLOOR((@year % 19.0 + (11 * ((( (19 * (@year % 19.0)) + FLOOR(@year / 100.0)) - FLOOR((@year / 100.0) / 4) - FLOOR((8 * (@year / 100.0) + 13) / 25.0) + 15) % 30))) / 319)) +32) % 7) + 90) / 25)) + 19) % 32,0)))),'Holiday','Good Friday' UNION ALL
    SELECT DATEADD(DAY,1,CONVERT(DATE,CONVERT(VARCHAR,@year) + '-0'+CONVERT(VARCHAR, FLOOR((((( (19 * (@year % 19.0)) + FLOOR(@year / 100.0)) - FLOOR((@year / 100.0) / 4) - FLOOR((8 * (@year / 100.0) + 13) / 25.0) + 15) % 30) - (FLOOR((@year % 19.0 + (11 * ((( (19 * (@year % 19.0)) + FLOOR(@year / 100.0)) - FLOOR((@year / 100.0) / 4) - FLOOR((8 * (@year / 100.0) + 13) / 25.0) + 15) % 30))) / 319)) + ((((2 * FLOOR((@year / 100.0)) % 4) + (2*((@year % 100) / 4))) - ((@year % 100) % 4) - ((( (19 * (@year % 19.0)) + FLOOR(@year / 100.0)) - FLOOR((@year / 100.0) / 4) - FLOOR((8 * (@year / 100.0) + 13) / 25.0) + 15) % 30) + (FLOOR((@year % 19.0 + (11 * ((( (19 * (@year % 19.0)) + FLOOR(@year / 100.0)) - FLOOR((@year / 100.0) / 4) - FLOOR((8 * (@year / 100.0) + 13) / 25.0) + 15) % 30))) / 319)) +32) % 7) + 90) / 25))+'-'+CONVERT(VARCHAR,CONVERT(INT,(((( (19 * (@year % 19.0)) + FLOOR(@year / 100.0)) - FLOOR((@year / 100.0) / 4) - FLOOR((8 * (@year / 100.0) + 13) / 25.0) + 15) % 30) - (FLOOR((@year % 19.0 + (11 * ((( (19 * (@year % 19.0)) + FLOOR(@year / 100.0)) - FLOOR((@year / 100.0) / 4) - FLOOR((8 * (@year / 100.0) + 13) / 25.0) + 15) % 30))) / 319)) + ((((2 * FLOOR((@year / 100.0)) % 4) + (2*((@year % 100) / 4))) - ((@year % 100) % 4) - ((( (19 * (@year % 19.0)) + FLOOR(@year / 100.0)) - FLOOR((@year / 100.0) / 4) - FLOOR((8 * (@year / 100.0) + 13) / 25.0) + 15) % 30) + (FLOOR((@year % 19.0 + (11 * ((( (19 * (@year % 19.0)) + FLOOR(@year / 100.0)) - FLOOR((@year / 100.0) / 4) - FLOOR((8 * (@year / 100.0) + 13) / 25.0) + 15) % 30))) / 319)) +32) % 7) + (FLOOR((((( (19 * (@year % 19.0)) + FLOOR(@year / 100.0)) - FLOOR((@year / 100.0) / 4) - FLOOR((8 * (@year / 100.0) + 13) / 25.0) + 15) % 30) - (FLOOR((@year % 19.0 + (11 * ((( (19 * (@year % 19.0)) + FLOOR(@year / 100.0)) - FLOOR((@year / 100.0) / 4) - FLOOR((8 * (@year / 100.0) + 13) / 25.0) + 15) % 30))) / 319)) + ((((2 * FLOOR((@year / 100.0)) % 4) + (2*((@year % 100) / 4))) - ((@year % 100) % 4) - ((( (19 * (@year % 19.0)) + FLOOR(@year / 100.0)) - FLOOR((@year / 100.0) / 4) - FLOOR((8 * (@year / 100.0) + 13) / 25.0) + 15) % 30) + (FLOOR((@year % 19.0 + (11 * ((( (19 * (@year % 19.0)) + FLOOR(@year / 100.0)) - FLOOR((@year / 100.0) / 4) - FLOOR((8 * (@year / 100.0) + 13) / 25.0) + 15) % 30))) / 319)) +32) % 7) + 90) / 25)) + 19) % 32,0)))),'Holiday','Easter Monday'
    update @table
    set date =
    case when MONTH(date) = 12 AND name != 'Boxing Day' and datepart(weekday,date) = 7 then dateadd(day,2,date)
    when MONTH(date) = 12 AND name != 'Boxing Day' and datepart(weekday,date) = 1 then dateadd(day,1,date)
    when MONTH(date) = 12 AND name = 'Boxing Day' and datepart(weekday,date) = 7 then dateadd(day,2,date)
    when MONTH(date) = 12 AND name = 'Boxing Day' and datepart(weekday,date) = 1 then dateadd(day,2,date)
    when MONTH(date) = 12 AND name = 'Boxing Day' and datepart(weekday,date) = 2 then dateadd(day,1,date)
    else date
    end
    return
    end
    GO
    create function Dates(@date datetime)
    returns @table table
    now datetime,
    today datetime,
    Month_start datetime,
    Month_end datetime,
    Prev_Month_Start datetime,
    Prev_Month_End datetime,
    Week_Start datetime,
    Week_End datetime,
    Prev_Week_Start datetime,
    Prev_Week_End datetime,
    Quarter_Start datetime,
    Quarter_End datetime,
    Prev_Quarter_Start datetime,
    Prev_Quarter_End datetime,
    Year_Start datetime,
    Year_End datetime,
    Prev_Year_Start datetime,
    Prev_Year_End datetime,
    Month_End_TS datetime,
    Prev_Month_End_TS datetime,
    Week_End_TS datetime,
    Prev_Week_End_TS datetime,
    Quarter_End_TS datetime,
    Prev_Quarter_End_TS datetime,
    Year_End_TS datetime,
    Prev_Year_End_TS datetime,
    Year smallint,
    Month smallint,
    Day smallint,
    Month_Name varchar(15),
    Day_Name varchar(15),
    WD SMALLINT,
    Week INT,
    isHoliday bit
    as
    begin
    if @date IS NULL set @date = getdate()
    insert into @table
    select
    @date as now,
    convert(datetime,convert(varchar,@date,101)) as today,
    dateadd(day,0-day(@date)+1,convert(datetime,convert(varchar,@date,101))) as Month_Start,
    dateadd(day,-1,dateadd(month,1,dateadd(day,0-day(@date)+1,convert(datetime,convert(varchar,@date,101))))) as Month_end,
    dateadd(month,-1,dateadd(day,0-day(@date)+1,convert(datetime,convert(varchar,@date,101)))) as Prev_Month_start,
    dateadd(day,-1-day(@date)+1,convert(datetime,convert(varchar,@date,101))) as Prev_Month_End,
    dateadd(day,1-datepart(dw,@date),convert(datetime,convert(varchar,@date,101))) as Week_Start,
    dateadd(day,7-datepart(dw,@date),convert(datetime,convert(varchar,@date,101))) as Week_End,
    dateadd(day,-6-datepart(dw,@date),convert(datetime,convert(varchar,@date,101))) as Prev_Week_Start,
    dateadd(day,0-datepart(dw,@date),convert(datetime,convert(varchar,@date,101))) as Prev_Week_End,
    convert(datetime,convert(varchar,year(@date)) +'-'+ right('0'+convert(varchar,((datepart(QUARTER,@date)-1)*3)+1),2)+'-01') as quarter_start,
    dateadd(day,-1,dateadd(quarter,1,convert(datetime,convert(varchar,year(@date)) +'-'+ right('0'+convert(varchar,((datepart(QUARTER,@date)-1)*3)+1),2)+'-01'))) as quarter_end,
    convert(datetime,convert(varchar,year(dateadd(quarter,-1,@date))) +'-'+ right('0'+convert(varchar,((datepart(QUARTER,dateadd(quarter,-1,@date))-1)*3)+1),2)+'-01') as prev_quarter_start,
    dateadd(day,-1,dateadd(quarter,1,convert(datetime,convert(varchar,year(dateadd(quarter,-1,@date))) +'-'+ right('0'+convert(varchar,((datepart(QUARTER,dateadd(quarter,-1,@date))-1)*3)+1),2)+'-01'))) as prev_quarter_end,
    dateadd(day,1-day(@date),dateadd(month,1-month(@date),convert(varchar,@date,101))) as Year_Start,
    dateadd(year,1,dateadd(day,0-day(@date),dateadd(month,1-month(@date),convert(varchar,@date,101)))) as Year_End,
    dateadd(year,-1,dateadd(day,1-day(@date),dateadd(month,1-month(@date),convert(varchar,@date,101)))) as Prev_Year_Start,
    dateadd(year,-1,dateadd(year,1,dateadd(day,0-day(@date),dateadd(month,1-month(@date),convert(varchar,@date,101))))) as Prev_Year_End,
    dateadd(ms,-3,dateadd(day,0,dateadd(month,1,dateadd(day,0-day(@date)+1,convert(datetime,convert(varchar,@date,101)))))) as Month_End_Ts,
    dateadd(ms,-3,dateadd(day,-1-day(@date)+2,convert(datetime,convert(varchar,@date,101)))) as Prev_Month_End_TS,
    dateadd(ms,-3,dateadd(day,8-datepart(dw,@date),convert(datetime,convert(varchar,@date,101)))) as Week_End_TS,
    dateadd(ms,-3,dateadd(day,1-datepart(dw,@date),convert(datetime,convert(varchar,@date,101)))) as Prev_Week_End_TS,
    dateadd(ms,-3,dateadd(day,0,dateadd(quarter,1,convert(datetime,convert(varchar,year(@date)) +'-'+ right('0'+convert(varchar,((datepart(QUARTER,@date)-1)*3)+1),2)+'-01')))) as quarter_end_TS,
    dateadd(ms,-3,dateadd(day,0,dateadd(quarter,1,convert(datetime,convert(varchar,year(dateadd(quarter,-1,@date))) +'-'+ right('0'+convert(varchar,((datepart(QUARTER,dateadd(quarter,-1,@date))-1)*3)+1),2)+'-01')))) as prev_quarter_end_TS,
    dateadd(ms,-3,dateadd(year,1,dateadd(day,1-day(@date),dateadd(month,1-month(@date),convert(varchar,@date,101))))) as Year_End_TS,
    dateadd(ms,-3,dateadd(day,1-day(@date),dateadd(month,1-month(@date),convert(varchar,@date,101)))) as Prev_Year_End_TS,
    Year(@date) as Year,
    Month(@date) as Month,
    Day(@Date) as Day,
    datename(month,@Date) as Month_Name,
    datename(WEEKDAY,@date) as Day_Name,
    datepart(weekday,@date) as WD,
    DATEPART(WEEK,@date) AS Week,
    COALESCE((SELECT 1
    FROM dbo.Holidays(YEAR(@date)) h
    WHERE h.date = @date),0) AS isHoliday
    return
    end
    go
    The holidays function is set up for Saskatchewan right now, but its a small matter to adjust it to your region.
    You can then do this:
    DECLARE @calendar TABLE (date DATE)
    WHILE (SELECT COUNT(*) FROM @calendar) < 365
    BEGIN
    INSERT INTO @calendar (date)
    VALUES (DATEADD(day,1,(SELECT COALESCE(MAX(date),CURRENT_TIMESTAMP) FROM @calendar)))
    END
    SELECT MONTH(date) AS month, MIN(date) AS fbd
    FROM @calendar c
    CROSS APPLY dbo.Dates(c.date)
    WHERE DATEPART(DAY,c.date) NOT IN (1,7) AND isHoliday = 0
    GROUP BY MONTH(date)

  • How to exclude weekends/holidays from BPEL Wait activity?

    I can configure the duration of a Wait activity using duration expressions, or specifying some time in the future. However, I have a use case where the Wait should only consider weekdays which are not holidays. Something akin to tying the Wait activity to a business calendar. Don't really need the sophistication of a business calendar, but at least would like to be able to only include weekdays and not weekends. I read somewhere that BPEL uses Quartz to implement the Wait activity.
    http://enterpriseglue.com/index.php?option=com_content&task=view&id=37&Itemid=44
    However, I can't find a way to configure the Wait for anything other than standard durations. Seems like Quartz does support the notion of business calendars. Here is a sample.
    http://www.quartz-scheduler.org/docs/cookbook/FifthWorkingDayTrigger.html
    If anybody has found a way to exclude weekends from the Wait activity in BPEL, or has some idea how it might be done, please share.

    Hi Harrie:
    Not sure I understand what you did. Suppose, for example, that I am setting the Wait duration to P5D. But I want to wait 5 business days instead of 5 calendar days. Do you first calculate what the end-time would be and then set the Wait expiration instead of the duration? In other words, waiting UNTIL a particular time, instead of waiting FOR a specified duration? Is this how you are doing it?
    Tks.

  • Trying to calculate value based on rounding up and then calculate date range excluding weekends..

    Hi
    I am creating a simple design studion project request form where the user can enter how many photographs need to be ordered. I am calling this field 'NumImages'. Then once the data is entered, another field (I am calling this NumDaysImage) will be calculated based on the fact that no more than 5 photographs can be shot per day. So, 1-5  photos = 1 day. 6-10 photos = 2 days. 11-15 photos = 3 days etc. I do not need to calculate part days, so 6 photos is the same as 10 i.e. 2 days.
    Once I have calcuated 'NumDaysImage', I then need to calculate an end date called 'DateDue'. The start date is entered by the user in the field 'DateStart'.
    I know this is not going to be easy, but how can I calculate 'DateDue' based on a Mon-Fri working week, and ideally excluding UK public holidays?
    Also on the form is a value 'NumDays' that is the number of days for designing the brochure for the photos. This value I have calculated already, but it will need to be added to 'NumDaysImage' to get a total number of production days that is then used to calculate 'DateDue'.
    Any help will be greatly appreciated. Thanks.

    JavaScript has the Math.ceil method which rounds up a number to the next integer if it is not an integer.
    Dates are more complicated calculation as the starting date needs to be converted to a number and then one can calculate the ending date and test that date to see if is a Sunday or Saturday. Do intervening weekends add to the number of days for processing.

  • ABAP HR- calculation of workind days (excluding weekend) for an employee

    Hi,
    I need to get number of working days between two dates excluding weekends for an employee. Please let me know below questions in this regard:
    1. I have to use Factory calender or holiday calender for this purpose?
    2. Will FM RKE_SELECT_FACTDAYS_FOR_PERIOD solve this purpose ?
    Regards,
    Aleria

    Hi Aleria,
    Use the FM DAY_ATTRIBUTES_GET in this FM pass the holiday and factory calendar of the employee along with the period. In the output structure if free day is set then it is SAT/SUN and if holiday is set then it is Public holiday marked in the calendar.
    Regards
    Bala

  • Calculating days excluding weekends

    Msy you please show me how to calculate the number of days in between 2 dates excluding weekends.

    Hi!
    Check out these FM-s:
    K_ABC_WORKDAYS_FOR_PERIODS_GET
    WEEK_GET_NR_OF_WORKDAYS      
    WLB3_GET_NUMBER_OF_WORKDAYS  
    There are some calendar relevant FM-s also. If there's set a production calendar in your SAP, you can check it also.
    SE37 transaction, and search for CALENDAR fm.
    Regards
    Tamá

  • How to exclude weekends & holidays from a date range

    Hi Friends,
    How can I exclude weekends & other holidays (which are specific to that country only) from a given range of date (if any weenends or holiday falls in that range)?
    Please supply some sample code if possible.
    Thanks in advance.

    Enayats_screen wrote:
    Hi
    I have found the relevant code for your help. May be this will solve your purpose. Please visit the below link
    http://www.simplyshareit.net/itemDetails.jsf?q=532&
    Thanks.Whew! Thank the gods you saved the OP from having to actually think or learn or clearly communicate his problem!

  • Finding the number of days excluding weekends

    Dear All,
    I want to find the date difference between the working days,
    ex, take 2 dates, today - Monday 11th and Monday 18th,
    So, I want a function module which will calculate the difference between working days, means from 18th to 11th, it should calculate the difference as 5 working days.
    Please let me know the function module which will show the number of difference in working days.
    Thanks in Advance,
    Ramana

    Hi,
    Check the following code:
    REPORT ZDATEDIFF.
    DATA: EDAYS   LIKE VTBBEWE-ATAGE,
          EMONTHS LIKE VTBBEWE-ATAGE,
          EYEARS  LIKE VTBBEWE-ATAGE.
    PARAMETERS: FROMDATE LIKE VTBBEWE-DBERVON,
                TODATE   LIKE VTBBEWE-DBERBIS DEFAULT SY-DATUM.
    call function 'FIMA_DAYS_AND_MONTHS_AND_YEARS'
      exporting
        i_date_from          = FROMDATE
        i_date_to            = TODATE
      I_FLG_SEPARATE       = ' '
      IMPORTING
        E_DAYS               = EDAYS
        E_MONTHS             = EMONTHS
        E_YEARS              = EYEARS.
    WRITE:/ 'Difference in Days   ', EDAYS.
    WRITE:/ 'Difference in Months ', EMONTHS.
    WRITE:/ 'Difference in Years  ', EYEARS.
    INITIALIZATION.
    FROMDATE = SY-DATUM - 60.
    Regards,
    Bhaskar

  • Days between two days except weekend

    Hi all he lp me in getting a oracle query to find out the days between 2 input dates excluding the weekends...

    >
    Hi all he lp me in getting a oracle query to find out the days between 2 input dates excluding the weekends...
    >
    Something like this should work
    with dates as (select sysdate fromDate, sysdate + 10 toDate from dual),
      days as (select sysdate + level - 0 myDay from dates
               connect by level < toDate - fromDate)
    select count(*) from days where to_char(myDay, 'Dy') not in ('Sat', 'Sun')
    COUNT(*)
    6The 'dates' query just provides the start and end dates. The 'days' query produces a date value for each day in the range between the start and end.
    Then the last query counts those days if they are not a Saturday or Sunday.
    You can adjust the 'days' query depending on whether you want both the start and end date included. For example if start is today and end is tomorrow (Friday) the above query result will be '1'.
    Are you forgetting to mark your questions ANSWERED when they have been? Total Questions: 12 (10 unresolved)

  • Removing Weekends in between two dates

    Hi,
    I need to get the number of days in between two dates excluding the weekends.
    Does anyone know how to do this?
    Thanks.

    Here's a search of the forum for "difference dates". At least the first three questions are identical to yours.
    http://search.java.sun.com/Search/java?col=javafrm&qp=%2Bforum%3A31&qt=difference+dates&x=12&y=10

  • Function Module for getting public holidays between two dates

    Dear Freinds,
                     I want  a function module which checks a day is public holiday or not based on the "HOLIDAY CALENDAR ID", i have
    found a function moudule('DATE_CHECK_WORKINGDAY') which checks a  holiday or not  but based on Factory Calender id,
    so could any one please let me know how can i get a day is a public holiday or not based on "HOLIDAY CALENDAR ID".
    regards
    divya.

    Hi,
    Use  HR_FORMS_READ_HOLIDAYS.
    pass calendar id, begin date, end date, holiday date.
    it will fetch the text of holiday... u can put a check that if the text fetched in initial then the holiday date u have passed is not a holiday..
    hope it helps

Maybe you are looking for

  • I need to restore an iphone 4 to 7.0.6 not the current 7.1

    I need to restore an passcode locked CMDA iPhone 4 to 7.0.6 not the current 7.1. This is due to a mobile management application that our company uses that has not been verified to work with 7.1 yet. This iPhone is current on 5.1.0. I am trying to do

  • Snow Leopard Time machine migration to Lion problem?

    I have a time machine backup of a mac with snow leopard that I made back in June. I want to put it on my new mac with Lion but it won't have this update - http://www.cultofmac.com/105225/if-you-want-to-migrate-from-snow-leopard-to-lion -tomorrow-you-

  • Extracting JES 2005Q04, Or JES2005Q01 giving error

    hi downloaded JES 2005Q04 part-1 and part-2 from sun's website when extracted it gives(WINRAR) that some files are missing. These happens for both release, Please share me some links from where I can download either of these release

  • Possible to get 'Automatic' device register without NSP ?

    Hi  Anybody pleade hint me config ISE1.2 I need to do separated ssid called on-board. Once non registed device comes in, ISE get sredirect to registering portal.  I can finish self fill in device register which user need to fill in his MAC manually.

  • Why can't I buy in iTunes....???

    hello..... i'm from mexico....... i have a .mac account.......... i have a paypal account....... i log in........ click on review info....... but i can't register a credit card because my billing info is not in the USA....... if i choose paypal......