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

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

  • 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;
    /

  • 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?

  • Function module for getting teh last working day of a month.

    Hi GURUS,
    this is criteria,please help me 
    if V_T001B- FRYE1 < month entered in selection screen
              Then throw the error message
                Else
    Find the previous period and its last working day from the function module
          (i..e Assume entered date as June 2 2009 then
                   Period 6 -1 = 5.
         Pass the month 05 to function module then
                   Find last working day.
                   Keep it in a variable (V_LAST_PRD_WRKDAY)
                           Proceed further.
    thanks in advance,
    Rajeev

    Hi Rajeev,
    You can use Function Module LAST_DAY_IN_PERIOD_GET.
    Ex:
          CALL FUNCTION 'LAST_DAY_IN_PERIOD_GET'
            EXPORTING
              i_gjahr = p_gjahr
              i_periv = lwa_t009b-periv
              i_poper = lwa_t009b-poper
            IMPORTING
              e_date  = s_audat-high.
    Regards,
    Ravi K

  • FM for Holiday & Next Working day

    HI All,
    Please suggest any  single FM, which can give the current day is Holiday or not. If, Yes, the what is the next working day for a Facorty calender ID.
    Both validation should be happend in a single FM.
    Thanks & Regards,
    Prabhakar.
    Moderator message: FAQ, please search for previous discussions of this topic.
    Edited by: Thomas Zloch on Apr 18, 2011 6:13 PM

    hi ,
    Pls check this FM
    CALL FUNCTION 'BKK_CHECK_HOLIDAY'
            EXPORTING
              i_date            = wf_cntdt
              i_calendar1       = 'B1'
            IMPORTING
              e_x_no_workingday = wf_holi.
    *get actual working days upto report date.
      it_act_work_days-dat_from  = w_date-low.
      it_act_work_days-dat_to    = w_date-high.
      APPEND it_act_work_days.
    *calculate actual working days.
      CALL FUNCTION 'WFCS_FCAL_WDAYS_GET_S'
        EXPORTING
          pi_time_interval = it_act_work_days
          pi_fcalid        = 'B1'
        IMPORTING
          pe_wdays         = wf_actdays.
    regards
    Deepak.
    Edited by: Deepak Dhamat on Apr 18, 2011 12:31 PM

  • Calculation of no. of working days (per Factory Cal) between 2 date chars

    This question could be considered to be in continuation of a previous post called "Working days of month with factory calendar"
    I have two date Characteristics: say Date1 and Date2. I need to find the number of working days between them based on the factory calendar.
    (And yes we have already defined the default factory calendar in IMG under 'General Reporting settings' ).
    The previous post proposed the following:
    1) Convert date1 into factorydate (standard functionmodule)
    2) Convert date2 into factorydate (standard functionmodule)
    Perform date1 - date2 to get number of working days.
    I agree that there is a std function module to convert cal date to factory date called: 'DATE_CONVERT_TO_FACTORYDATE'
    But what are the steps for calling the conversion? Should I create a new Formula variable of 'Customer Exit type' give it a name and define the Function module in CMOD? But then how do I attach the formula variable to the date characteristic. Note that my infoobjects are Chars so I cannot do date1- date2 in the query as is possible with keyfigures!
    Please help! (my version is BW 3.0)
    Thanks
    Naresh

    Hi,
    For the above scenario when you need to calculate date 1 - date 2. we can't build a new formulae or calculated KF directly because those are the chars.
    So we need make chars to act as KF through Formulae with replacement path.
    create a formulae variable on those 2 Date chars with Processing type as replaccement then those 2 Dates can be avilable to build a formulae as ur requirement.
    Let me know if you need any more information.
    Thanks,
    Raju

  • Date calculations based on working days

    I need to add date calculations to a worksheet to show the time elapsed between two actions.
    Just a straightforward subtraction works fine, but what I really need to be able to do is calculate the number of working days between the two point (as something taking 5 days over Christmas with the 2 bank holidays is different equivalent to something taking 3 days in a normal week)
    At the moment I'm exporting the data into excel for analysis of this, but would really like to be able to do it in Disco so that the end users can go straight to the report using viewer, rather than having to do the conversion for them.
    Is this possible?
    Cheers

    Hi,
    Every thing is possible, the Q is how complicated is it....
    My suggestion is to create a table with all the dates of the non-working days for ex:
    create a table with all the MON-THURSDAYS, union to this table the holidays you know of such as christmas and so on.
    After getting this table you can create a function that returns the number of working days between 1 date to another by subtracting the days exists in this table.
    I started with that, you are more then welcome to get ahead with it and let us know what happened...
    create table holiday
    D_date date,
    d_day varchar2(20)
    create or replace procedure holiday_proc is
    d_date date;
    begin
    d_date := trunc(sysdate);
    while d_date<'01-jan-2010'
    loop
    if to_char(trunc(d_date),'Day') not in ('Saturday ','Sunday ') then
    INSERT INTO Holiday (d_date,d_day)
    (select trunc(d_date),to_char(trunc(d_date),'Day') from dual);
    end if;
    d_date := d_date+1;
    end loop;
    commit;
    end holiday_proc;

  • How is lead time in working days calculated in 2LIS_05_QVUDN

    I was wondering if someone knows how lead time is being caclulated for 2LIS_05_QVUDN.  I've found the tables associated and the function module but I can't find the actual calculation
    Thanks

    Hello
    The lead time in working days works like this
    If you have 1 inspection lot for a material   -the time from  Lot creation to Usage decision given  is the lead time.
                                                              Lot created               Usage Decision made       Lead Time
    for eg Material X , inspection lot no   14/05/2008 10: 00          14/05/2008 14: 00            4 Hours
    it converts the hours in to days . =4/24= 0.16 days
    For total lead time individual lot's lead time sum is calculated
    Hope this clarifies your doubt
    Regards
    gajesh

  • Work day calculator

    Hi All, I'd like to do a function in Numbers whereby a day is considered as 8h and I can then multiply a day rate by this.
    I want to enter the data as days and hours.
    eg:
    Header 1
    Duration
    Day rate
    Header 4
    01d 4h -> (this is calculated as 1.5 days)
    $400
    $600
    01d 9h -> (automatically corrects to 2d 1hr -> 2.125)
    $400
    $850
    0d 5h -> (calculated as .625 days because 8hr day)
    $400
    $250
    any help appreciated

    I think you will add lots of complexity trying to use the duration (which can represent  Weeks Days Hours Minutes Seconds and Milliseconds)
    If you enter in hours only (just a number like, 12) not as a duration ("1d 4h" or "12h") you can computer Work Days like this.
    Assume you enter work hours in cell B2 AND
    that a work day is the same as 8 hours
    C2=B2/8

  • ABAP - Function module to get the number of working days between 2 days

    Hi gentlemen,
    I have been asked to produce a report that gives the number of working days between 2 days, based on a calendar.
    I didn't find anything...
    Has any of you already written a function module to get this ?
    A great thanks in advance.
    Jacques Lagrif

    Hi ,
    you can try this ,
    when you require the number of working days between D1 and D2
    Total No of Days will be
    D2 - D1
    No of holidays between D1 and D2 , use the FM HOLIDAY_GET
    Pass the From date , to date , and the factory calendar to get the of Holidays
    Total no of days - Number of Holidays will your Working days
    Regards,
    Sathya

  • How to set the payment Due date calculation as per working days.

    how to make changes in the vendor Payment terms so that while calculating the Payment due date as per Payment terms, system calculates it based on Working Days & not the Calender days ?
    Help is much appriciated.
    Thank you,
    Amit

    Hi,
    This is the standard settings by SAP, normally we couldn't change it to working day.
    Good luck
    Tao

  • 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?

  • Calculating the planned delivery time in calendar days or working days

    Hi,
    It seems that there is a way to calculate the planned delivery time in calendar days instead of working days.
    When I use the "Planned delivery time calculation" (WPDTC), in Evaluation Options, I got the message :
    "Note that follow-on applications are currently interpreting the planned delivery time as calendar days.
    If they should be interpreting the planned delivery time as working days, you need to modify these applications. If the planned delivery time should be calculated in working days, there needs to be a factory calendar in Customizing with the calendar ID Country of vendor."
    When MRP create a PR -with MDBT, MD03 or MD01- I want my Planned delivery time to be in working days.
    I can't manage to make that "If the planned delivery time should be calculated in working days, there needs to be a factory calendar in Customizing with the calendar ID Country of vendor."
    I would appreciate your help.
    Thanks
    PYR

    Hi,
    I understand that it makes sense that vendors calendar has to be different (compared to my plant).
    But, I still don't understand why in the SAP help, they say "If the planned delivery time should be calculated in working days, there needs to be a factory calendar in Customizing with the calendar ID Country of vendor."
    It seems that planned delivery time may follow a calendar.
    Thanks,
    PYR

  • Function  in param, start_date & number , return sums next working day

    Hi Friends,
    I need a funtion which can take in parameters as start_date and number , sum them as new date and return new_start_date as workind day.
    Suppose '15-SEP-2009' + 6 should return 23-SEP-2009 as new date.
    Basically the sum of date and number should return next working day (excluding saturday,sunday).
    e.g '15-SEP-2009' + 6 =21-SEP-2009 , but it includes saturday and sunday , so it should return 23-SEP-2009.
    Thanks
    Niren

    Hi, Niren,
    The first respondent gave a better function for testing for work days (Monday through Friday). If there's a bug with Saturdays, I'm sure that can fixed. Also,that function depends on your NLS settings. If that's an issue for you, that can be fixed, too. The idea that there are 5 work days in any 7 consecutive days will cut down the execution time considerable.
    A function like I suggested would be useful if you had to consider holidays as well as weekends.
    Here's an untested example:
    CREATE OR REPLACE FUNCTION  work_days_away
    (      in_start_date         DATE
    ,      in_day_cnt         NUMBER
    RETURN     DATE
    DETERMINISTIC
    IS
         IF  in_start_date - TRUNC (in_start_date, 'IW') >= 5
         OR  is_holiday (in_start_date)
         THEN
              RETURN  work_days_away ( in_start_date + 1
                               , in_day_cnt
         ELSIF  in_day_cnt >= 1
         THEN
              RETURN  work_days_away ( in_start_date + 1
                               , in_day_cnt    - 1
         ELSE
              RETURN  in_start_date;
         END IF;
    END     work_days_away;This use the date format 'IW', which does not depend on NLS settings, rather than 'D', which does.

Maybe you are looking for

  • Ajax not working in Chrome

    I am using Ajax and ASP in my dynamic pages to display content. However the code works alright in IE but the Ajax and javascript does not function in Chrome. Please advise on how to ensure this.

  • Problem with Submit statement

    Hi All, I have a problem with the usage of the submit statement. I have a report program, say report 'A'. In the report program 'A', I have a custom screen with number '9001'. In the screen 9001, of program A, there is a button to display ALV. In the

  • I have OS 10.5 and can not download the new version of Itunes for my new phones. What can I do?

    I have OS x 10.53 and my new phones will not recognize the version of Itunes. What fix is there that will allow my phones to work with Itunes? Thanks Ken

  • SWT vs SWING

    Anyone here can help me decide about what�s the better enivoronmente to develope low-consumption resource app, SWT or SWING. I have some desktop ERP application developed with SWING but i have poor results (responsiveness talking). Also we have here

  • TS3367 How can I change my FaceTime # in settings???

    How can I change my FaceTime # in settings???