Function for calculating working days

Dear Oracle
Is there any function to calculate no of working days if I pass From date & To date?.
Thanks
Christy.

This would work for normal weekdays, but what about bank holidays?
They change from country to country, so you need to create a package yourself.
We got one that looks like the following:
create or replace
package body zentr_date_functions as
  function eastern (p_year in number) return date is
    -- Get easter sunday (working from 1900 to 2099)
    -- CKL 02.09.1998 nach c't 18/98
    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 this 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
      -- fixed date bank holidays in lower saxony, Germany
      return 0;
    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
      -- calculation not possible
      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
      -- good friday, easter monday, ascension day, pentecost monday
      return 0;
    end if;
    return 1;
  end is_workday;
  function workdays_between (p_date1 in date, p_date2 in date) return number as
    -- count number of working days between  p_date1 and p_date2 (incl. both)
    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;
/

Similar Messages

  • Calculating Work Day Formulas

    We've recently adopted BOBJ/Webi at my company and I find the software to be rather easy to use in some instances and mind-wreckingly hard in others. One roadblock myself and other users are bumping into is calculating work days. A definition of a work day in this instance would be Monday through Friday. The monkey wrench is that we would also like to subtract out holidays, such as July 4th and Thanksgiving. Then end product would be calculating out what work day the current date is and how many days it is out of so that a simple straight-line extrapolation can be made (Metric/Current Work Day)*Total Work Days. Also, what we invoice/ship is not accounted for until the following day... for example, today (2.22.10) would be the 15th workday in February out of 20 total work days.
    Appreciate any and all help/assistance/counsel I can get on this.
    Ryan

    Hi Ryan,
    If I have understood your question then I think following solution may help you.
    Do you have your Universe created on the top of BW query or is it some other Database?
    If it is some other database then create couple of Filter at Universe level: Such as Holidays so that you can use this one to subtract holidays:
    For Example:
    ucase(Calendar_year_lookup.Holiday_Flag)
    ucase(Calendar_year_lookup.Holiday_Flag) = 'Y'
    Then you create another Dimension for Work days that would be between Monday to Friday.
    Once they are created in Universe you export Universe.
    Now create a formula where you would use month minus custom dimension workdays and minus holidays to get actual work days which would be from Monday to Friday and son on.
    Basically we can achieve this by using filters and formulas.
    Wish you good luck.
    Bashir Awan

  • Calculating work days in a function

    I have a function that will count the total number of days between two weeks. ie May 19, 2010 to June 18, 2010 is 30 total days in my cycle. We dont work on weekend so that 30 days is not correct. The formula below is how i'm calculating the days between cycles. Is there any way to not count the weekends in my cycle? Please see formula below:
    TIMESTAMPDIFF(SQL_TSI_DAY, "Release Dim"."Release Cycle Start Date", "Release Dim"."Release Cycle End Date")

    Thanks Hammett81.
    I used your formula but it's still calculating the days in my cycle as 30. My start date comes from my column "Release Dim"."Release Cycle Start Date" and my end date comes from the column "Release Dim"."Release Cycle End Date". Can you tell me why the formula below is giving me the weekends included in my count?
    Thanks a million for all your help.
    TIMESTAMPDIFF(SQL_TSI_DAY,TIMESTAMPADD( SQL_TSI_DAY, 7-DAYOFWEEK("Release Dim"."Release Cycle Start Date"),"Release Dim"."Release Cycle Start Date"),TIMESTAMPADD(SQL_TSI_DAY, 7-DAYOFWEEK("Release Dim"."Release Cycle End Date"),"Release Dim"."Release Cycle End Date"))+ CASE 7-DAYOFWEEK("Release Dim"."Release Cycle Start Date") WHEN 6 THEN 5 ELSE 7-DAYOFWEEK("Release Dim"."Release Cycle Start Date") END-CASE 7-DAYOFWEEK("Release Dim"."Release Cycle End Date") WHEN 6 THEN 5 ELSE 7-DAYOFWEEK("Release Dim"."Release Cycle End Date") END

  • Function for finding first day of the month !!

    Hi,
    I know we have function to find the last day(DD) of the month. Do we have any functions for finding the first day of the month ??? if not is there any way i can find the first date(DD) of the month .
    Bcoz i m trying to incorporate the logic for finding the first day of the month partition.
    Thank you!!!

    Shahid Ali Tcs wrote:
    There are many solution given by member in relation with your question, and all are correct .
    I want to make u know something else.
    Have you ever think why oracle has given function for last_day but no function for first.....
    I u think this question u will get the answer of your "first day finding " question.
    Because first day is alwasy 01 of every, while last day can be 30,31,29,28.....
    Got my words ........
    One more solution from my side,,,,
    SQL> select '01' || to_char(sysdate,'-MON-YY') from dual;
    '01'||TO_
    01-SEP-09Which is a completely poor way of doing it.
    Using TRUNC or LAST_DAY(..) + 1 will return a DATE datatype result.
    Your method is converting the DATE into a VARCHAR2, which then prevents further processing/date based calculations unless it is explicitly converted back to a DATE again.
    The reason Oracle hasn't provided a FIRST_DAY is because the TRUNC function already caters for it as this works with DATE's as well as NUMBER's, not because the first day is always 1.

  • Suggestions on calculating work days instead of Calendar days

    Hi there,
    I would like for someone to suggest how would I approach a project in calculating a date that would consider if a date is a holiday or a work day. For example: If I take current date + 7 normally it would be a week (7 days). However, if a day in that week is a holiday, then it would return the 8th day. If the 8th day falls into a weekend, then, get the next work date.
    Any ideas would be greatly appreciated.
    Thanks for your assistance in advance.

    Thanks. This give me a pretty good start. I am thinking that I need a table that store holidays (Non-work days excluding weekend). Once I load this table into memory, then I would check the first date + 7. Then compare the two dates against the array to see if there is a holiday. If there is, then I would increment the end date by 1 and validay if it is a weekend date. If it is, I would continue to incurement until it is nolonger an weekend date. Once I have that, I would check the date against the array (where I left off) and continue to validate to see if there are more holidays.
    What do you think about this approach?

  • Display data for last working day of month

    Hi
    I am trying to chart values for the last six years but only to plot the value for the last working day of the month, except for the current month where I am taking an average of the month so far. Everything I've tried has so far failed spectacularly. Has anyone resolved a similar problem?

    If I understand your dilemma correctly, you may want to create a cross-tab and then create the chart off of the cross-tab. Is the data in your tables that you want to chart on something like this:
             4/30   5/30   6/30   7/31   8/29       Sept.
    Row 1    20      30      10      25      20    (avg for month) 
    Row 2    5         10      8       15     15    (avg for month)
    etc.
    If so, 1) can you show an example of the data and 2) what kind of chart do you want to create?

  • Mass approval functionality for SRM work items

    Hi,
    We want to implement mass approval functionality for SRM workflow, so that any user is able to approve/reject multiple requests at one go through UWL.
    Please guide if it is possible to implement this functinality for task id TS40007952.
    Regards,
    Avantika

    Hi Avantika,
    The mass approval functionality can be implemented for simple workflow items which have decisions to complete the work item. (User Decision Type)
    In SAP Business Workflow, user can define a task as a decision task by assigning DECISION as the underlying business object type. The task definition allows user to create two or more decision options to complete the task.
    The idea is to simply create a custom view/subview for the UWL item and configure it according to your needs.
    Have a look at this blog:
    Mass/Batch Processing of Work items in UWL
    and also check the documentation:
    http://help.sap.com/saphelp_nw70ehp1/helpdata/en/4e/72112bc9ea484196f2a5fdc68f5f5f/frameset.htm
    Let me know if you have any questions.
    Thanks,
    Shanti

  • Leave for non working day

    Hi,
    We have a project called as capita for whom our employees are sheeting on their office, and their holiday calendar and our holiday calendar is different some of our employee who are in capita they applied leave on 10th sep which was a holiday in Mastek but it was a working day for capita .
    Neither we can make a new holiday calendar for capita nor can we frame a new absence type, because by doing this there are some possibility of violating our hr policy.
    So kindly suggest us the best possibility.
    We are patch level 58

    Hello sir,
    When entering absences the counts the planned working time which is included between begin and end of the absence. On off-days or public holidays the sum of working hours always is zero. 
    From a business point of view it does not make much sense to record an absence for an employee on a day on which he/she  does not have to work.
    Unfortunately you cannot override this. If you need to record an absence on a day off you will have to create a substitution record so that day is now a working day.
    The following information might be helpful:
    After a change in a holiday calendar the work schedules have to be regenerated. The warning message you described on the first page comes out of a check against the work schedule. In IMG you can find Personal Time Management -> Work Schedules -> Work Schedule Rules and Work Schedules -> Generate Work Schedules Manually Here the work schedules have to be generated after any change in the holiday calendar.

  • Authorization to disable SAP Inbox Forward function for specific Work Items

    Hi.
    I recently solved a case for a customer of mine regarding authorizations for work items. They have several workflows running, but for this specific custom developed workflow, users should not be allowed to use the SAP Inbox Forward button.
    I started by creating a new task classification (Z_FW) which I implemented on the workflow tasks where the forward functionality should be disabled. Now for test purposes I created a dummy user which I initially gave only authorization to the tcode SBWP, then I manually added the authorization object S_WF_WI.
    For this entry I allowed all activities for work item type W and F for classification 1, 2, 3 and NO_CLASS (SAP Standard classification).
    Now to my understanding this would give the test user authorization to perform all activities on Work Items and Workflows which are classified with one of the above, but also prevent me from doing anything with Workflows and Work Items with classification Z_FW.
    However, to my surprise everything seems to work perfectly with just this entry. I am able to execute and forward work items with the standard classification, while I am able to execute, but not forward, work items with classification Z_FW.
    My intention was to add another entry for authorization object S_WF_WI, for classification Z_FW with all activities except forwarding. But when I tried that, the only change was that forwarding was enabled for the work items with classification Z_FW, which I didnu2019t want.
    Now can anyone explain to me why this is working? I am not too familiar with SAP Authorization as my area is mainly ABAP and WF, but his just does not seem logical.
    Hoping someone can give me an explanation....
    Thanks

    Does the standard function not do what you want?
    Task -> Additional data -> Agent Assignemt -> Maintain -> Attributes -> Forwarding not allowed.

  • Function module for calculating next day's date

    Dear all,
    We have a requirement of displaying transaction validity date on SAP smart form. The date input is available from the transaction.
    We need to add 1 day to this to get correct date printed in the output. We applied the logic of 'input date +1', but this logic does not give correct output when the final date co-incides with change in month (i.e 1st of next month).
    Is there any function module available which would do the addition in proper date format and calculate next day's date correctly?
    Regards,
    DS

    Use FM RP_CALC_DATE_IN_INTERVAL
    Example :
    data: v_curr type sy-datum,
    v_next type sy-datum.
    v_curr = '20080415'.
    CALL FUNCTION 'RP_CALC_DATE_IN_INTERVAL'
    EXPORTING
    DATE = v_curr
    DAYS = '01'
    MONTHS = '0'
    SIGNUM = '+'
    YEARS = 0
    IMPORTING
    CALC_DATE = v_next.
    write:/5 'Current date', v_curr.
    write:/5 'Future date', v_next.

  • SQL Function for calculating IP Address

    Hi Experts ,
    I have an IP Range i need to find out the First Host detail for the IP using a SQL scalar function .
    Example : 11.30.10.40
    Subnet Mask is 26
    Output required
    First host: 11.30.10.1
    am confused how i can derive the first host  values from a sql function kindly help .
    Thanks
    Priya

    DECLARE @Mask TINYINT = 26;
    DECLARE @AddressIP VARCHAR(15)= '11.30.10.40';
    DECLARE @AddressValue BIGINT = PARSENAME(@AddressIP,4)*CAST(256*256*256 AS BIGINT)+PARSENAME(@AddressIP,3)*256*256+PARSENAME(@AddressIP,2)*256+PARSENAME(@AddressIP,1);
    WITH
    n0(n) AS (SELECT 0 UNION ALL SELECT 0)
    ,n1(n) AS (SELECT 0 FROM n0 a CROSS JOIN n0)
    ,n2(n) AS (SELECT 0 FROM n1 a CROSS JOIN n1)
    ,n3(n) AS (SELECT 0 FROM n2 a UNION ALL SELECT 0 g FROM n2)
    ,t (n) AS (SELECT ROW_NUMBER() OVER (ORDER BY (SELECT NULL)) FROM n3)
    ,bits(b,v) AS (SELECT n,POWER(CAST(2 AS BIGINT),32-n) FROM t)
    SELECT @AddressIP [Address]
    ,CAST((SUM(v) / 256 / 256 / 256) % 256 AS VARCHAR(3)) + '.' + CAST((SUM(v) / 256 / 256) % 256 AS VARCHAR(3)) + '.' + CAST((SUM(v) / 256) % 256 AS VARCHAR(3)) + '.' + CAST(SUM(v) % 256 AS VARCHAR(3)) [Netmask]
    ,CAST(((SUM(v) ^ 0xFFFFFFFF) / 256 / 256 / 256) % 256 AS VARCHAR(3)) + '.' + CAST(((SUM(v) ^ 0xFFFFFFFF) / 256 / 256) % 256 AS VARCHAR(3)) + '.' + CAST(((SUM(v) ^ 0xFFFFFFFF) / 256) % 256 AS VARCHAR(3)) + '.' + CAST(((SUM(v) ^ 0xFFFFFFFF)) % 256 AS VARCHAR(3)) [Wildcard]
    ,CAST(((@AddressValue & SUM(v)) / 256 / 256 / 256) % 256 AS VARCHAR(3)) + '.' + CAST(((@AddressValue & SUM(v)) / 256 / 256) % 256 AS VARCHAR(3)) + '.' + CAST(((@AddressValue & SUM(v)) / 256) % 256 AS VARCHAR(3)) + '.' + CAST(((@AddressValue & SUM(v))) % 256 AS VARCHAR(3)) + '/' + CAST(MAX(b) AS VARCHAR(2)) [NetworkAddress]
    ,CAST(((((SUM(v) ^ 0xFFFFFFFF)) | @AddressValue) / 256 / 256 / 256) % 256 AS VARCHAR(3)) + '.' + CAST(((((SUM(v) ^ 0xFFFFFFFF)) | @AddressValue) / 256 / 256) % 256 AS VARCHAR(3)) + '.' + CAST(((((SUM(v) ^ 0xFFFFFFFF)) | @AddressValue) / 256) % 256 AS VARCHAR(3)) + '.' + CAST(((((SUM(v) ^ 0xFFFFFFFF)) | @AddressValue)) % 256 AS VARCHAR(3)) [BroadcastAddress]
    ,CAST(((@AddressValue & SUM(v)) / 256 / 256 / 256) % 256 AS VARCHAR(3)) + '.' + CAST(((@AddressValue & SUM(v)) / 256 / 256) % 256 AS VARCHAR(3)) + '.' + CAST(((@AddressValue & SUM(v)) / 256) % 256 AS VARCHAR(3)) + '.' + CAST(((@AddressValue & SUM(v))) % 256 + 1 AS VARCHAR(3)) [FirstHost]
    ,CAST(((((SUM(v) ^ 0xFFFFFFFF)) | @AddressValue) / 256 / 256 / 256) % 256 AS VARCHAR(3)) + '.' + CAST(((((SUM(v) ^ 0xFFFFFFFF)) | @AddressValue) / 256 / 256) % 256 AS VARCHAR(3)) + '.' + CAST(((((SUM(v) ^ 0xFFFFFFFF)) | @AddressValue) / 256) % 256 AS VARCHAR(3)) + '.' + CAST(((((SUM(v) ^ 0xFFFFFFFF)) | @AddressValue)) % 256 - 1 AS VARCHAR(3)) [LastHost]
    ,(((SUM(v) ^ 0xFFFFFFFF)) | @AddressValue) - (@AddressValue & SUM(v)) - 1 [TotalHostCount]
    FROM bits WHERE @Mask BETWEEN 1 AND 32 AND b <= @Mask
    Jon

  • User - defined functions for calculating the taxes of state and country

    hi expects,
        how can write user-defined function in message mapping in which i want to calculate the states taxes (2500) and country taxes (5000) and give the result as grand total in output.please help me?

    Hi,
    Activities
    1. To create a new user-defined function, in the data-flow editor, choose Create New Function (This
    graphic is explained in the accompanying text), which is located on the lower left-hand side of the
    screen. In the menu, choose Simple Function or Advanced Function.
    2. In the window that appears, specify the attributes of the new function:
    Name
    Technical name of the function. The name is displayed in the function chooser and on the data-flow
    object.
    Description
    Description of how the function is used.
    Cache
    Function type (see above)
    Argument Count
    In this table, you specify the number of input values the function can process, and name them. All
    functions are of type String.
    3. In the window that appears, you can create Java source code:
    a. You can import Java packages to your methods from the Imports input field, by specifying them
    separated by a comma or semi-colon:
    You do not need to import the packages java.lang., java.util., java.io., and java.lang.reflect. since
    all message mappings require these packages and therefore import them. You should be able to
    access standard JDK and J2EE packages of the SAP Web Application Server by simply specifying the
    package under Import. In other words, you do not have to import it as an archive into the Integration
    Repository. You can also access classes of the SAP XML Toolkit, the SAP Java Connector, and the
    SAP Logging Service (see also: Runtime Environment (Java-Mappings)).
    In addition to the standard packages, you can also specify Java packages that you have imported as
    archives and that are located in the same, or in an underlying software component version as the
    message mapping.
    b. Create your Java source text in the editor window or copy source text from another editor.
    4. Confirm with Save and Close.
    5. User-defined functions are limited to the message mapping in which you created the function. To
    save the new function, save the message mapping.
    6. To test the function, use the test environment.
    The new function is now visible in the User-Defined function category. When you select this category,
    a corresponding button is displayed in the function chooser pushbutton bar. To edit, delete, or add the
    function to the data-flow editor, choose the arrow next to the button and select from the list box
    displayed.
    Regards
    Seshagiri

  • Add Working Days Function

    All,
    I have created the following function to add working days to a date...
    create or replace function add_working_days(
    p_days in number,
    p_dt in date default trunc(sysdate)
    return date
    as
    v_weeks number;
    v_adj number;
    begin
    v_weeks := trunc(p_days/5);
    if to_number(to_char(p_dt,'D')) + mod(p_days,5) >= 7 then
    v_adj := 2;
    else
    v_adj := 0;
    end if;
    return p_dt + 7*v_weeks + v_adj+mod(p_days,5);
    end add_working_days;
    I am then calling the function to default a date field.
    The hassle is that it keeps setting the year to 0006 instead of 2006.
    Any suggestions?
    Cheers,
    Gart

    Gart,
    I ran your code -
    SQL> select sysdate from dual;
    SYSDATE
    24-JAN-06
    SQL> select to_char(sysdate, 'Day') as Today from dual;
    Today
    Tuesday
    SQL> select
      next_working_date,
      to_char(next_working_date, 'Day') as next_working_day
    from
      (select add_working_days(4, sysdate) as next_working_date from dual)
    SQL> /
    NEXT_WORKING_DATE    NEXT_WORKING_DAY
    30-JAN-06            MondaySo it seems to work for me, are you sure it's not your NLS settings or your date formatting code that isn't displaying the year correctly?

  • Standard variable exist for calendar day that uses current working day

    Hi
    Is there any standard range Variable that exists for info-object calendar day that uses the manual entry for the lower limit and upper limit as current working day .
    Please advise.
    Thanks.

    There are a number of standard variables 0n 0CALDAY - of processing type SAP exit, Input Allowed, Select-option or Range. You will have to check whether they give the default value of current date though as that will have to be looked up from documentation or user-exit code (or from the name of variable).
    To shorten the candidate list, SE16 on table RSZGLOBV where
    OBJVERS = D (Delivered version)
    IOBJNM = 0CALDAY
    VARTYP = 1
    VARPROCTYP = 4 (SAP Exit)
    VPARSEL = I, S (Range or select-option)
    VARINPUT = 'X' (Ready for input)
    It should give you about 6-7 variables that you can explore further. It is likely that none of these default to current date. Some of these are
    0DAY_***
    0TWB_30T
    0CDL12CM
    0I_CCMDR
    0CD_L14D
    0S_CALDAY
    0CD_L7D
    I see that you are looking for current 'working' day as default. Very likely the answer is 'no' in such case.
    Edited by: Ajay Das on Mar 1, 2011 7:39 AM

  • 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

  • Report with bind variables

    Hi, I apologize in advance for the newbie question. I would like to create a report report_b with a "vertical report exclude null values" template which will show only one record. This report will be called from another report with a default template

  • ITunes x64 can't open - Windows 7 x64

    I cannot open my iTunes x64 on my Windows 7 x64 operating system. I reinstalled it but it still hasn't been working. When I go into iTunes store, it says "We are unable to find iTunes on your computer." I don't have a problem with QuickTime.

  • Question about widget

    what are the cool widgets the I could download that won't mess up with my system? are the following widgets such as istat, geoWidget, mtv and hotbox good to download? What is plasma tube? is Geowidget same as google earth?

  • Spring-Ibatis-Ldap configuration

    Hi , im trying to connect to ldap datasource connection using spring and ibatis. But getting an exception org.apache.commons.dbcp.SQLNestedException: Cannot create PoolableConnectionFactory (LDAP Does Not Support Transactions) This is how my .xml fil

  • Userexit for IDOC_INPUT_DESADV1

    Hi everyone,                this is my first idoc assignment.....  I have a requirement where in ASN IDOC is sent to ECC from another system.  I need to process the idoc and generate inbound delivery.. But there are few translation to be made on the