Calculate Business day

Hi,
Iam working on a logic to calculate the posting date in XI. I have used graphical mapping in the scenario.
The logic is to claculate the 3rd business date of the month. You need to look at the calendar and exclude Saturdays, Sundays and Holidays.
For example if we take February 2008 the 3rd business day is 5th Feb 08 as 02/Feb and 03/Feb are saturday and sundays.
If monday(04/Feb) was a holiday then the 3rd business day will be 6th Feb.
Can you give this logic in XI graphical mapping.
Best Regards
Suresh

Hi Ram,
Thanks for the immediate reply. The XI scenario is File to IDOC. But the scenario is already developed using graphical mapping and I just need to change the posting date logic in it. I believe the holidays are maintained in SAP tables. Is there a way to get the holidays list from SAP using User defined functions in XI.
Best Regards
Suresh

Similar Messages

  • 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

  • Calculate "Business Days" and account for holidays

    I have played with Date math based on what I have found for documentation, and adding an arbitrary number of days is pretty easy. But what about adding an arbitrary number of business days? I found a web site that talks about "Next business day",
    which could be adapted I am sure, but it only accounts for weekends. I want to calculate the date an arbitrary number of business days from a provided date. So, +3 business days calculated from a Monday should produce the date of the following Thursday,
    and calculated from a Friday should produce the date of the next Wednesday. And calculated from Friday Sept 4, 2015 (Friday before Labor Day) should produce Thursday Sept 10, 2015.
    Given that Windows is very business focused, I wonder if there is some nice hidden .NET functionality to calculate business days based on holidays as well? I know, some offices might give extra days off, four day weekends, etc. But those would be edge case
    enough to be safely ignorable for my purposes. Indeed, even holidays could probably be ignored, but if there is a quick approach I would rather use it. If I would need to code some sort of Exchange calendar scraper or some such, I'll live with just accounting
    for weekends. ;)

    You can pull holiday info from outlook.hol file and do the date math based on it. It won't be 100% reliable though. Not all the holidays listed in calendar are non-business days (not in all countries at least). International support may also present additional
    issues: in some countries it is a common practice to "move" weekend days to fill a single day gap between holidays and weekend (which screws up next business day calc anyway, regardless of holiday info :-). Not to mention all the possible industry-wide
    or company specific policies regarding working days.
    Gleb.

  • Calculate business day between two dates

    Hi Guys
    I need the count of business days between two  dates
    Date1, Date2 i need the count only business day (exclude sartuday&sunday)
    If date1 is null or nothing i need to pass 0
    If date2 is null or nothing i need to pass 0
    help on this

    Hi,
    To achive this within SSRS, go to the report code window and add the below
    Function getBusinessDaysCount(ByVal tFrom As Date, ByVal tTo As Date) As Integer
    Dim tCount As Integer
    Dim tProcessDate As Date = tFrom
    For x as Integer= 1 To DateDiff(DateInterval.Day, tFrom, tTo) + 1
    If Not (tProcessDate.DayOfWeek = DayOfWeek.Saturday Or tProcessDate.DayOfWeek = DayOfWeek.Sunday) Then
    tCount = tCount + 1
    End If
    tProcessDate = DateAdd(DateInterval.Day, 1, tProcessDate)
    Next
    Return tCount
    End Function
    In the textbox where you need to display the value, add the below expression
    =Code.getBusinessDaysCount(parameters!StartDate.Value,parameters!EndDate.Value)
    It is assumed the you want to pass the two days from parameters named Startdate and EndDate. If not, modify the expression with required values.
    Regards
    Please click "Mark as Answer" if this resolves your problem or "Vote as Helpful" if you find it helpful. BH

  • Query to calculate business days

    i have table name order table . in that i have column name install date,order date.
    the difference bet ween order date and install date should be greate than or equal to 3 working days.
    fri and sat are holidays.
    i need one query to find the difference betwwen orderdate and install date is greate than 3 working days

    You can try like this
    SQL> with order_tbl
      2  as
      3  (
      4    select to_date('01-jan-2013', 'dd-mon-yyyy') order_date
      5         , to_date('05-jan-2013', 'dd-mon-yyyy') installed_date
      6      from dual
      7    union all
      8    select to_date('04-jan-2013', 'dd-mon-yyyy') order_date
      9         , to_date('07-jan-2013', 'dd-mon-yyyy') installed_date
    10      from dual
    11    union all
    12    select to_date('06-jan-2013', 'dd-mon-yyyy') order_date
    13         , to_date('15-jan-2013', 'dd-mon-yyyy') installed_date
    14      from dual
    15    union all
    16    select to_date('19-jan-2013', 'dd-mon-yyyy') order_date
    17         , to_date('25-jan-2013', 'dd-mon-yyyy') installed_date
    18      from dual
    19    union all
    20    select to_date('25-jan-2013', 'dd-mon-yyyy') order_date
    21         , to_date('30-jan-2013', 'dd-mon-yyyy') installed_date
    22      from dual
    23  )
    24  select order_date, installed_date, count(date_list) date_count
    25    from (
    26            select t.*, t.order_date + (level-1) date_list
    27              from order_tbl t
    28            connect by level <= installed_date - order_date + 1
    29               and prior order_date = order_date
    30               and prior sys_guid() is not null
    31         )
    32   where to_char(date_list, 'fmday') not in ('saturday', 'sunday')
    33   group
    34      by order_date, installed_date
    35  /
    ORDER_DAT INSTALLED DATE_COUNT
    19-JAN-13 25-JAN-13          5
    25-JAN-13 30-JAN-13          4
    04-JAN-13 07-JAN-13          2
    01-JAN-13 05-JAN-13          4
    06-JAN-13 15-JAN-13          7
    SQL> In the above code i have used the WITH clause to generate sample data. you can just use the SELECT query alone.

  • Calculate: SYSDATE + TWO BUSINESS DAYS

    Is there a simple way (function) in 10g to calculate
    - "SYSDATE + TWO BUSINESS DAYS (not including Saturday)"
    - "SYSDATE + TWO BUSINESS DAYS (including Saturday)"
    in SQL ? Or I have to write a function to calculate manually?
    Thank you for any idea.

    One possible solution, based on a table of holidays:
    CREATE TABLE HOLIDAY_TABLE
    (HOLIDAY_DATE DATE PRIMARY KEY,
    DESCRIPTION VARCHAR2(50));
    SELECT dt
      FROM (SELECT dt, RANK () OVER (ORDER BY dt) pos
              FROM (SELECT     TRUNC (SYSDATE) + LEVEL dt,
                               CASE
                                  WHEN TRIM (TO_CHAR (SYSDATE + LEVEL, 'DAY')) = 'SATURDAY'
                                   OR TRIM (TO_CHAR (SYSDATE + LEVEL, 'DAY')) = 'SUNDAY'
                                  THEN 0
                                  ELSE 1
                               END cnt
                          FROM DUAL
                    CONNECT BY LEVEL < 7)      -- number large enough to generate a complete list of possible days
             WHERE cnt = 1 AND (SELECT COUNT (*)
                                  FROM holiday_table
                                 WHERE holiday_date = dt) = 0)
    WHERE pos = 2  -- number of working days to add Miguel

  • How to calculate previous business day

    Hi,
    I'm stuck with an issue.
    Task is to calculate 1 to 6 previous business days with reference to system date.
    Conditions are : Week is 6 day. In first case its Sunday as weekend holiday and in second case its Saturday as weekend holiday.
    Another condition is I have to take care of bank holidays also which are stored in a separate table in database.
    How to implement this logic ?
    Below I have implemented some logic but its not running correctly for some dates adjusted according to bank holidays.
    In this code I'm taking Sunday as weekend off and To_Date is having the list of bank holidays for 2012.
    SELECT
      CASE
        WHEN TRUNC(SYSDATE-1) IN (TO_DATE('01-JAN-2012'), TO_DATE('02-JAN-2012'), TO_DATE('07-APR-2012'), TO_DATE('09-APR-2012'), TO_DATE('07-MAY-2012'), TO_DATE('04-JUN-2012'), TO_DATE('05-JUN-2012'), TO_DATE('27-AUG-2012'), TO_DATE('25-DEC-2012'), TO_DATE('26-DEC-2012'))
        THEN (
          CASE
            WHEN TRUNC(SYSDATE-2) IN (TO_DATE('01-JAN-2012'), TO_DATE('02-JAN-2012'), TO_DATE('07-APR-2012'), TO_DATE('09-APR-2012'), TO_DATE('07-MAY-2012'), TO_DATE('04-JUN-2012'), TO_DATE('05-JUN-2012'), TO_DATE('27-AUG-2012'), TO_DATE('25-DEC-2012'), TO_DATE('26-DEC-2012'))
            Then (
            CASE
            WHEN TRUNC(SYSDATE-3) IN (TO_DATE('01-JAN-2012'), TO_DATE('02-JAN-2012'), TO_DATE('07-APR-2012'), TO_DATE('09-APR-2012'), TO_DATE('07-MAY-2012'), TO_DATE('04-JUN-2012'), TO_DATE('05-JUN-2012'), TO_DATE('27-AUG-2012'), TO_DATE('25-DEC-2012'), TO_DATE('26-DEC-2012'))
            Then (
            CASE
            WHEN TRUNC(SYSDATE-4) IN (TO_DATE('01-JAN-2012'), TO_DATE('02-JAN-2012'), TO_DATE('07-APR-2012'), TO_DATE('09-APR-2012'), TO_DATE('07-MAY-2012'), TO_DATE('04-JUN-2012'), TO_DATE('05-JUN-2012'), TO_DATE('27-AUG-2012'), TO_DATE('25-DEC-2012'), TO_DATE('26-DEC-2012'))
            Then (       
            CASE
            WHEN TRUNC(SYSDATE-5) IN (TO_DATE('01-JAN-2012'), TO_DATE('02-JAN-2012'), TO_DATE('07-APR-2012'), TO_DATE('09-APR-2012'), TO_DATE('07-MAY-2012'), TO_DATE('04-JUN-2012'), TO_DATE('05-JUN-2012'), TO_DATE('27-AUG-2012'), TO_DATE('25-DEC-2012'), TO_DATE('26-DEC-2012'))
            Then (       
            CASE
            WHEN TRUNC(SYSDATE-6) IN (TO_DATE('01-JAN-2012'), TO_DATE('02-JAN-2012'), TO_DATE('07-APR-2012'), TO_DATE('09-APR-2012'), TO_DATE('07-MAY-2012'), TO_DATE('04-JUN-2012'), TO_DATE('05-JUN-2012'), TO_DATE('27-AUG-2012'), TO_DATE('25-DEC-2012'), TO_DATE('26-DEC-2012'))
            THEN DECODE(TO_CHAR((SYSDATE-6),'DAY'),'MONDAY   ',TRUNC((SYSDATE-6)-7),'TUESDAY  ',TRUNC((SYSDATE-6) - 7),'WEDNESDAY',TRUNC((SYSDATE-6) - 7),'THURSDAY ',TRUNC((SYSDATE-6) - 7),'FRIDAY   ',TRUNC((SYSDATE-6) - 7),'SATURDAY ',TRUNC((SYSDATE-6) - 7),'SUNDAY   ',TRUNC((SYSDATE-6) - 6))
            ELSE DECODE(TO_CHAR((SYSDATE-5),'DAY'),'MONDAY   ',TRUNC((SYSDATE-5)-7),'TUESDAY  ',TRUNC((SYSDATE-5) - 7),'WEDNESDAY',TRUNC((SYSDATE-5) - 7),'THURSDAY ',TRUNC((SYSDATE-5) - 7),'FRIDAY   ',TRUNC((SYSDATE-5) - 7),'SATURDAY ',TRUNC((SYSDATE-5) - 7),'SUNDAY   ',TRUNC((SYSDATE-5) - 6))
            END)
            ELSE DECODE(TO_CHAR((SYSDATE-4),'DAY'),'MONDAY   ',TRUNC((SYSDATE-4)-7),'TUESDAY  ',TRUNC((SYSDATE-4) - 7),'WEDNESDAY',TRUNC((SYSDATE-4) - 7),'THURSDAY ',TRUNC((SYSDATE-4) - 7),'FRIDAY   ',TRUNC((SYSDATE-4) - 7),'SATURDAY ',TRUNC((SYSDATE-4) - 7),'SUNDAY   ',TRUNC((SYSDATE-4) - 6))
            END)
            ELSE DECODE(TO_CHAR((SYSDATE-3),'DAY'),'MONDAY   ',TRUNC((SYSDATE-3)-7),'TUESDAY  ',TRUNC((SYSDATE-3) - 7),'WEDNESDAY',TRUNC((SYSDATE-3) - 7),'THURSDAY ',TRUNC((SYSDATE-3) - 7),'FRIDAY   ',TRUNC((SYSDATE-3) - 7),'SATURDAY ',TRUNC((SYSDATE-3) - 7),'SUNDAY   ',TRUNC((SYSDATE-3) - 6))
            END)
            ELSE DECODE(TO_CHAR((SYSDATE-2),'DAY'),'MONDAY   ',TRUNC((SYSDATE-2)-7),'TUESDAY  ',TRUNC((SYSDATE-2) - 7),'WEDNESDAY',TRUNC((SYSDATE-2) - 7),'THURSDAY ',TRUNC((SYSDATE-2) - 7),'FRIDAY   ',TRUNC((SYSDATE-2) - 7),'SATURDAY ',TRUNC((SYSDATE-2) - 7),'SUNDAY   ',TRUNC((SYSDATE-2) - 6))
          END )
              ELSE DECODE(TO_CHAR((SYSDATE-1),'DAY'),'MONDAY   ',TRUNC((SYSDATE-1)-7),'TUESDAY  ',TRUNC((SYSDATE-1) - 7),'WEDNESDAY',TRUNC((SYSDATE-1) - 7),'THURSDAY ',TRUNC((SYSDATE-1) - 7),'FRIDAY   ',TRUNC((SYSDATE-1) - 7),'SATURDAY ',TRUNC((SYSDATE-1) - 7),'SUNDAY   ',TRUNC((SYSDATE-1) - 6))
          END)
        ELSE DECODE(TO_CHAR((SYSDATE),'DAY'),'MONDAY   ',TRUNC((SYSDATE)-7),'TUESDAY  ',TRUNC((SYSDATE) - 7),'WEDNESDAY',TRUNC((SYSDATE) - 7),'THURSDAY ',TRUNC((SYSDATE) - 7),'FRIDAY   ',TRUNC((SYSDATE) - 7),'SATURDAY ',TRUNC((SYSDATE) - 7),'SUNDAY   ',TRUNC((SYSDATE) - 6))
      END
    FROM DUAL;Edited by: user9082359 on Oct 21, 2012 8:55 PM

    Hello,
    There are two business streams.
    For one stream,Saturday is holiday and for other Sunday is holiday and
    ('01-JAN-2012'), ('02-JAN-2012'), ('07-APR-2012'), ('09-APR-2012'), ('07-MAY-2012'), ('04-JUN-2012'), ('05-JUN-2012'), ('27-AUG-2012'), ('25-DEC-2012'), ('26-DEC-2012') is my list of bank holidays for 2012 year.
    Now if suppose we have to calculate 1 previous business day for today 22 Oct,it would be 20 Oct for one stream and 21 Oct for another stream.
    Like this I have to calculate 1-6 previous business days for sysdate.
    Now If there is a bank holiday coming in between e.g. suppose 20 Oct is a bank holiday and Sunday is weekend holiday,so now 1 previous business day would be 19 Oct.
    I hope I have made myself clear.
    Thanks and waiting for solution of this issue.

  • Calculate number of Business Days

    I need to calculate number of Business Days in BODS. Lets say I have One source table and One Date Dimension table to identify Business Day and need to calculate the no of working days and load in to FACT table (Like in screenshot below)?
    By adding Query transform, I can calculate no of Days, but how to calculate working days between ORDER_RECEIVED_DATE and ORDER_SHIPPED_DATE.
    SQL: select count(*) from DIM_DATE  where DATE between ORDER_RECEIVED_DATE and ORDER_SHIPPED_DATE and HOLIDAY_FLAG='NO'

    Prashanth Chinta,
    I have simulated this Job in my repository and and below are the steps by step implementation.
    Your Dataflow will look like below. It contains the source and Target table with expected results. Hope this is what you are looking for.
    DIM_DATE table contains all the dates in a year and mark each date either Holiday as 'YES' or 'NO'
    Qry_Total_Ship_Days Query Transform
    Qry_Join Query Transform
    Qry_Filter_Holidays Query Transform
    Qry_Cnt_Holidays Query Transform
    Qry_Cnt_Holidays Query Transform (This is to show the groupby columns)
    Qry_Cal_Ship_Days Query Transform

  • Formula to calculate due date considering only business days (Middle East)

    I have a form which contains two fields: 'Start Date' and 'Completion Date'; the 'Completion Date' field is automatically set, it's always 3 more days than the 'Start Date' field.
    The problem is that these 3 days must be only business days.
     - if 'Start Date' is on Sunday then the 'Completion Date' should be set to next Wednesday
     - if 'Start Date' is on Monday then the 'Completion Date' should be set to next Friday
     - if 'Start Date' is on Tuesday then the 'Completion Date' should be set to next Sunday
     - if 'Start Date' is on Wednesday then the 'Completion Date' should be set to next Monday
     - if 'Start Date' is on Thursday then the 'Completion Date' should be set to next Tuesday
     - if 'Start Date' is on Friday then the 'Completion Date' should be set to next Tuesday
     - if 'Start Date' is on Saturday then the 'Completion Date' should be set to next Tuesday
    Friday and Saturday should be ignored as 'Completion Date' (weekend in Middle East).
    Anyone has any idea of how to make this formula? I need to put it into a calculated SharePoint column.
    Thanks in advance for your help.

    Hi
    check my post
    http://www.romeodonca.ro/Lists/DB_IT/Adding%20a%20number%20of%20working%20days%20to%20a%20specific%20date
    If you need more details let me know
    Romeo Donca, Orange Romania (MCSE, MCITP, CCNA) Please Mark As Answer if my post solves your problem or Vote As Helpful if the post has been helpful for you.

  • Formula to calculate due date considering only business days

    Hello,
    I have a form which contains two fields: 'Start Date' and 'Due Date'.  The 'Due Date' field is automatically set , it's always 4 more days than the 'Start Date' field. 
    The problem is: Those 4 days must be only business days... e.g., if 'Start Date' is on Friday then the 'Due Date' should be set on the next Thursday. Saturday and Sunday are ignored. Anyone has any idea of how to make this formula? I need to put it into
    a calculated SharePoint column.
    Thanks in advance.

    Hello,
    you can use this calculated formula for Due Date:
    =IF(WEEKDAY(StartDate+4)=7,StartDate+6,IF(WEEKDAY(StartDate+4)=1,StartDate+5,StartDate+4))
    Be aware that it treats holidays and national bank holidays as business days unless they are on a weekend. 
    cheers, teylyn
    teylyn,
    Thank you for your example. However this formula doesn't seem to be entirely correct, right? Because
    according to the excel spreadsheet you sent, when the Start Date is May 29th (Thursday), Due Date
    will be on June 2nd (Monday) taking so only two days rather than four.
    Maybe a little change in this formula and we will be fine.

  • Service Requests-Business days when year changes

    Hi All,
    I am trying to calculate for how long a SR has been open in business days only.
    I have successfully used Mike Lairson's formula for the last 9 months but it seems it cannot cope with year changes. If the begin data is in 2009 and the end date in 2010, the results are not correct anymore.
    E.G. For an SR that was opened on 12/30/2009 and closed on 01/05/2010 should return 5 business days but it is actually returning 110.
    The syntax that I used so far is:
    (CASE
    /* Convert Sunday to the Business Day Of the Year */
    WHEN DAYOFWEEK("Service Request"."Closed Date and Time") = 1
    THEN (DAYOFYEAR("Service Request"."Closed Date and Time") - WEEK("Service Request"."Closed Date and Time")) -
    (WEEK("Service Request"."Closed Date and Time") - 2)
    /* Convert Saturday to the Business Day Of the Year */
    WHEN DAYOFWEEK("Service Request"."Closed Date and Time") = 7
    THEN (DAYOFYEAR("Service Request"."Closed Date and Time") - WEEK("Service Request"."Closed Date and Time")) -
    (WEEK("Service Request"."Closed Date and Time") - 1)
    /* Convert Mon-Fri to the Business Day Of the Year */
    ELSE (DAYOFYEAR("Service Request"."Closed Date and Time") -
    WEEK("Service Request"."Closed Date and Time")) +
    (2 - WEEK("Service Request"."Closed Date and Time")) END)
    (CASE
    /* Convert Sunday to the Business Day Of the Year */
    WHEN DAYOFWEEK("Service Request"."Opened Date") = 1
    THEN (DAYOFYEAR("Service Request"."Opened Date") -
    WEEK("Service Request"."Opened Date")) -
    (WEEK("Service Request"."Opened Date") - 2)
    /* Convert Saturday to the Business Day Of the Year */
    WHEN DAYOFWEEK("Service Request"."Opened Date") = 7
    THEN (DAYOFYEAR("Service Request"."Opened Date") -
    WEEK("Service Request"."Opened Date")) -
    (WEEK("Service Request"."Opened Date") - 1)
    /* Convert Mon-Fri to the Business Day Of the Year */
    ELSE (DAYOFYEAR("Service Request"."Opened Date") -
    WEEK("Service Request"."Opened Date")) +
    (2 - WEEK("Service Request"."Opened Date"))
    END)
    +
    /* Adjust for Year Change */
    (365 * (YEAR("Service Request"."Closed Date and Time") -
    YEAR("Service Request"."Opened Date")))
    Any ideea or hint would be highly appreciated.
    Thank you.
    Regards,
    Dorin
    Edited by: user805960 on 06.01.2010 07:07

    Hi,
    i used this formula to find out the days it calculates between 31/12/2009 and 01/01/2010, the result it gave was 106 days.
    So i subtracted 106 from 365 days (365-106=259)in the formula, the formula is now giving the correct values.
    I think we have to add the total working days and not the no.of days in a year.
    Please can you all reconfirm the results.
    Thanks
    Neena
    Edited by: NNK on Jan 11, 2010 3:16 PM

  • Calculation of due date based on Business Days for FICA documents

    Hi All,
    I am working on project where SD - FICA integration is in picture. We post some charges through SD and FICA document gets posted on relevant Contract Account.
    Normally we create Sales Order using transaction VA01 and then we do Billing for this Sales Order through VF01. After billng is done, FICA document automatically gets generated.
    We have following requirement to be fulfilled.
    For the SD bills posted as above, I want to calculate due date of these bills based on Business Days for FICA document generated (SAP Standard calculate due date based on Calander days). We can use factory calander for calculating business days in relevant function module.
    I have checked in the system and it seems that event 1330 ( FM - ISU_DUE_DATE_DETERMINE) is not working in this scenario. Is there any other FM which I can use?
    Can anyone help me on this?
    Regards,
    Pradeep

    Hello Praeva ,
    The event 1330 has a sample FM FKK_SAMPLE_1330. It doesnt even have a Standard Function Module.
    You need to create a Installation-Specific FM and put your code to determine the Due Date based on the logic.
    Rgds
    Ram Kumar.

  • Oracle 8i: Business Days Calculation in a Subquery

    To Whom It May Concern:
    I apologize if this has been posted already, but I didn't find any threads that address my issue:
    I need to find the number of business days between 2 dates (excludes weekends) provided by dates from an outer query such as the following:
    SELECT
         C.CUSTOMER_ID
         , C.ENTRY_DATE
         , C.COMPLETION_DATE
         , <SOME SUBQUERY HERE THAT CALCULATES THE NUMBER OF BUSINESS DAYS BETWEEN C.COMPLETION_DATE AND C.ENTRY_DATE> AS BUSINESS_DAYS
    FROM CUST_TABLE C
    Thanks for your time and advice.
    Max

    you don't need a subquery. it's a very simple formula
    Re: query regarding dates
    (you may need to change the case to a decode for v8 - I don't remember when it was introduced)

  • Adding Business Days to a Date to create New Date

    I am looking to add a formula to auto calculate a new date, but only want to count business Days.
    Currently I am using formula to calculate how many days need to be added:
    //ODD Priority Business Days
    If left ({DEFECT.PRIORITY}, 1)= "1" then 10    
    else  
    If left ({DEFECT.PRIORITY}, 1)= "2" then 20
    else
    If left ({DEFECT.PRIORITY}, 1)= "3" then 50
    else
    If left ({DEFECT.PRIORITY}, 1)= "0" then 10
    Now I need to create a formula to add these numbers to the date field, for conversation purposes, I need to add these business days to my "start date" to equil my "ODD date".
    Example, if my "start date" is 1/1/2009 and it is a Priority 2, then I need to add 20 business days to that, so the "ODD date" would be: 1/29/2009.
    Please help.

    Thank you Garrett Fitzgerald! Please see the modified formula which I meant
    {Startdate}
        + {@BusinessDays}
        - DateDiff("ww", {Startdate}, {Startdate} + {@BusinessDays}, crSaturday)
        - DateDiff("ww", {Startdate}, {Startdate} + {@BusinessDays}, crSunday)
    Regards,
    Raghavendra

  • Is there a function to derive "business days" only

    Is there either an Oracle SQL built-in function or user-defined function for calculating the difference
    between two dates or between SYSDATE and a date in the database, which uses business days
    only (at least excluding weekends)?
    I'd appreciate any help on this!
    Thanks!
    Kathy Kuehnle
    [ [email protected] ]

    We solved this with the following package:
    create or replace
    package body zentr_date_functions as
      function eastern (p_year in number) return date is
        -- Calculate easter sunday (valid from 1900 to 2099)
        -- based on a Gauss algorithm
        l_a pls_integer;
        l_b pls_integer;
        l_c pls_integer;
        l_d pls_integer;
        l_e pls_integer;
        l_p pls_integer;
        function make_date(p_d in pls_integer, p_m in pls_integer, p_y in pls_integer) return date is
        begin
          return to_date(to_char(p_d, '00')||to_char(p_m, '00')||to_char(p_y, '0000'), 'DDMMYYYY');
        end;
      begin
        if p_year not between 1900 and 2099 then
          return null;
        end if;
        l_a := mod(p_year, 19);
        l_b := mod(p_year, 4);
        l_c := mod(p_year, 7);
        l_d := mod(19 * l_a + 24, 30);
        l_e := mod(2 * l_b + 4 * l_c + 6 * l_d + 5, 7);
        l_p := 22 + l_d + l_e;
        if l_p > 31 then
          if l_p = 56 and l_d = 28 and l_a > 10 then
            return make_date(18, 4, p_year);
          elsif l_p = 57 then
            return make_date(19, 4, p_year);
          else
            return make_date(l_p - 31, 4, p_year);
          end if;
        else
          return make_date(l_p, 3, p_year);
        end if;
      end eastern;
      function is_workday (p_date in date) return number as
        -- Is p_date a working day?
        l_eastern date;
      begin
        if to_char(p_date, 'DY', 'NLS_DATE_LANGUAGE = AMERICAN') in ('SAT', 'SUN') then
          return 0;
        end if;
        if to_char(p_date, 'DDMM') in ('0101', '0105', '0310', '2412', '2512', '2612', '3112') then
          return 0; -- fixed bank holidays in lower saxony, Germany
        end if;
        if to_number(to_char(p_date, 'MM')) not between 3 and 6 then
          return 1;
        end if;
        if to_number(to_char(p_date, 'YYYY')) not between 1900 and 2099 then
          return null;
        end if;
        l_eastern := eastern (to_number(to_char(p_date, 'YYYY')));
        if trunc(p_date) in (l_eastern - 2, l_eastern + 1, l_eastern + 39, l_eastern + 50) then
          return 0; -- eastern depentent bank holidays in lower saxony, Germany
        end if;
        return 1;
      end is_workday;
      -- This is what you are looking for:
      function workdays_between (p_date1 in date, p_date2 in date) return number as
        -- count number of workdays between p_date1 and p_date2 (both p_date1 and p_date2 included).
        l_count pls_integer := 0;
      begin
        for i in 0 .. p_date2 - p_date1 loop
          l_count := l_count + is_workday(p_date1 + i);
        end loop;
        return l_count;
      end workdays_between;
    end;

Maybe you are looking for

  • How can I organize my files in files panel;images, videos etc?

    I am begining to have a lot of files in my files panel. I have a folder for images but when I put the images there dreamweaver does not know where to find them, even though I specified this when setting up.  I am now begining to get a lot of videos a

  • Error can t Download the Music iTunes Match

    Error can t Download the Music iTunes Match

  • How to mount my raid now?

    Hello, I had my raid working somehow through my fstab, but I did an upgrade yesterday and now it's not working and everything looks different now.... here is lsblck sdb           8:16   0   1.8T  0 disk  └─md126       9:126  0   1.8T  0 raid1   └─md1

  • Export von PDF

    Hoffe, dass ich in deutsch fragen kann. Mein InDesign CS 6 V. 8.0 (OS X 10.6.8) stürzt immer mal wieder beim Export von PDF-Dateien ab. Bei CS 5.5 passiert das nicht. Gibt es eine Hilfe? Freundliche Grüße Kurt Ott Antwort gerne auch an: [email protec

  • Mountain Lion update and phone number

    When I want to use the up-to-date program and get a version of Mountain Lion my Danish phone number doesn't work. What do I do?