Calculate the days of salary

Dear friend


I want to calculate the days of salary. We pay the salaries of the 21st of the month last to the 20th of the current month.

I want to create a view where it will show of the the Scriptures based on this month wise condition

Select empno, name, daytype, count (empno) days, MAX (TO_CHAR (ADATE, 'MONTH')) in dailyattendence
When al > =('20-OCT-2010') AND ADATE < =('20-NOV-2010')
Group by empno, daytype
order by empno


for ex

562 SEUN BÉLANGER AFTERNOON OCTOBER 1
562 SEUN BÉLANGER MORNING OCTOBER 2
562 SEUN BÉLANGER NIGHT OCTOBER 2
562 SEUN OFF BÉLANGER 1 OCTOBER

562 SEUN BÉLANGER AFTERNOON NOVEMBER 1
562 SEUN BÉLANGER MORNING 2 NOVEMBER
562 SEUN BÉLANGER NIGHT NOVEMBER 2
562 SEUN OFF BÉLANGER 1 NOVEMBER

Suggest me how to set the dates so that I can get the report as shown above,

Sandy

It doesn't really have anything to do with the forms, but here's a solution.
To get the 21st of the month before you use:

select to_date('21'||to_char(add_months(sysdate,-1),'mmyyyy'),'ddmmyyyy')
from dual;

TO_DATE('
---------
21-OCT-10

The same for the 20th of this month. So you get:

where adate between to_date('21'||to_char(add_months(sysdate,-1),'mmyyyy'),'ddmmyyyy')
   and to_date('20'||to_char(sysdate,'mmyyyy'),'ddmmyyyy')

An addition: If your date includes a time, you must use the use trunc (date).

Published by: InoL on November 11, 2010 12:10

Tags: Oracle Development

Similar Questions

  • Function to calculate the days of work

    Hi all

    I accidentally develop an application in which I had to follow the thread below and it works perfectly for the weekend (Saturday and Sunday)

    PL/SQL function to calculate the non-working days

    Now, my specific question is: how to implement the same function , but weekends (Fri & sat).

    I tried to recognize the logic behind the calendar to change the days of the weekend, but I suspect.

    I need your recommendation around this function specifically.

    !-[CodeBlockStart:3cad70b5 - 81 a 0-4f6b-909 a-cacb29e25953]--> BOX WHEN IN l_case (-"Mon6", "Tue5", "Wed4", "Thu3", "Fri2" - exclude Saturday & Sunday, workday begins from Monday 'Sun6', 'Mon5', 'Tue4', 'Wed3', 'Thu2' - remove begins day 2 business days (Fri & sat) on Sunday and maintaining the order of the sequences,-"Sat1", "Sun1", "Sun2', 'Sun3', 'Sun4' - Include weekend can be for the rest of the week) , "Sat1", "Sat2", 'Fri1', "Sat3", "Sat4" - includes my week ends replace (with FRI Sat) & (Sun to SAT) & law enforcement-sequence, "Sun5', 'Sun6',"Sat5","Sat6"- replace (Sun with Sam).                                                                   ) 1 THEN WHEN IN l_case (-'Tue6', 'Wed5', 'Wed6', 'Thu4', "Thu5" - Old (Saturday and Sunday) end over the next week - I guess - sequence of days - since the week days sequence Changed (number 1 or 1 step backward) when numbers also changed accordingly "Tue5", "Wed4", "Wed5", "Thu3", "Thu4" - ok-, 'Thu6', 'Fri3', "Fri4", "Fri5", "Fri6", "Thu5", "Sun1", "Sun2", 'Sun3', 'Sun4' - contiue to Thu sequence number & then replace my current (Friday) holiday with start of work dat (Sun) "Fri1") (, 'Fri2', 'Fri3', 'Fri4', "Fri5") THEN 2 0 OTHERWISE END;

    Thanks in advance.

    Amatu Allah

    with

    calendar as

    (select dat_val,

    cases where to_char(dat_val,'mm-dd') in (12-25', 12-26', ' 01-01')-in fact select the host table to_char(holiday_date,'mm-dd')

    then "vacation."

    When to_char (dat_val, 'Dy') in ('Friday', 'Saturday')

    then 'weekend '.

    else 'work '.

    end dat_type

    sum (case when to_char(dat_val,'mm-dd') in (12-25', 12-26', ' 01-01'))

    then 0

    When to_char (dat_val, 'Dy') in ('Friday', 'Saturday')

    then 0

    1 other

    end

    ) on working_count (dat_val control)

    from (select date "' 2015-12-01 + level - 1 dat_val)

    of the double

    connect by level<=>

    )

    )

    Select dat_val,

    dat_type,

    working_count

    calendar

    where dat_val between to_date(:lo_date,'yyyymmdd') and to_date(:hi_date,'yyyymmdd')

    and dat_type! = work «»

    DAT_VAL DAT_TYPE WORKING_COUNT
    11/12/2015 end of week 8
    12/12/2015 end of week 8
    18/12/2015 end of week 13
    19/12/2015 end of week 13
    25/12/2015 holiday 18
    26/12/2015 holiday 18
    01/01/2016 holiday 23
    02/01/2016 end of week 23
    08/01/2016 end of week 28
    09/01/2016 end of week 28

    Select to_date(:lo_date,'yyyymmdd') lo_date,

    to_date(:hi_date,'yyyymmdd') hi_date,

    dat_val,

    dat_type,

    working_count,

    Lead (working_count) more (order of dat_val) - working_count + 1 working_days,

    to_date(:hi_date,'yyyymmdd') - to_date(:lo_date,'yyyymmdd') - lead (working_count) (order dat_val) + working_count non_working_days

    calendar

    where dat_val in (to_date (:hi_date,'yyyymmdd'),to_date(:lo_date,'yyyymmdd'))

    LO_DATE HI_DATE DAT_VAL DAT_TYPE WORKING_COUNT WORKING_DAYS NON_WORKING_DAYS
    10/12/2015 10/01/2016 10/12/2015 work 8 22 10
    10/12/2015 10/01/2016 10/01/2016 work 29 - -

    Concerning

    Etbin

  • calculate the day of the year using the date.

    Hi all
    Can calculate us the day of the year using the date form? Is this possible? Please help me thanks in advance
    Like this
    30/08/2009-30/08/2010 after calculation - 365


    Sarah

    Published by: SarahSarahSarah on August 30, 2009 12:49 AM

    Sarah.

    : ins1.noday must be a part of number!

    Create a function in forms like this:

    function get_nodays ( f_dtm_start in date,
                          f_dtm_end   in date ) return number is
    begin
    if
      f_dtm_start is null OR
      f_dtm_end is null
    then
      return ( null );
    end if;
    return ( trunc ( f_dtm_start ) - trunc ( f_dtm_end ) );
    exception when others
    then message ( sqlerrm || ' in function get_nodays occured.' );
    return ( null );
    end;
    

    Call this function in the when-validate-point triggers on ins1. INSPERIOD and: ins1.end love

    :ins1.noday := get_nodays ( :ins1.INSPERIOD, :ins1.end );
    

    It is redundant to have the: noday as a cause of part of database
    the value may by calculated every time using the values INSPERIOD and: end.

  • to calculate the days of sheets each month

    Hi all

    I need a query which can get leaves from an employee of days each month.

    Example:

    1.

    If an employee has leave of date_start = 15 January 2014 ', date_end = 30 January 2014 "which is in the same month, then it will be"

    Duration = 15-30 + 1 = 16 days

    Total_days_in_jan = 31 days

    Calculation of salary leave will be amount = (: base +: housing) * (: duration) / (Total_days_in_jan)

    = (1000 + 2000) * 16/31

    ' 2. If his two month date_start = 15 January 2014 ', date_end = 10 February 2014.

    I wrote code that works perfect below

    If to_char(:date_start,'mm') = to_char(:date_end,'mm') then

    v_mon_days: = TO_CHAR (last_day (TO_DATE(:date_start,'DD-MON-YYYY')), 'DD');

    v_tot: = (nvl(:BASIC1,0) + nvl (:FUJ_LIVING,0)) *(:Duration_)/v_mon_days;

    elsif to_char(:date_start,'mm') <>to_char(:date_end,'mm') then

    v_mon_days_st_dt: = TO_CHAR (last_day(:date_start), 'DD');

    v_mon_days_en_dt: = TO_CHAR (last_day(:date_end), 'DD');

    v_lv_days_st_dt: = last_day(:date_start) -: date_start + 1;

    v_lv_days_en_dt: =: date_end - trunc(:date_end,'mm') + 1;

    v_tot_st_dt: = (nvl(:BASIC1,0) + nvl(:FUJ_LIVING,0)) * (v_lv_days_st_dt) / v_mon_days_st_dt;

    v_tot_en_dt: = (nvl(:BASIC1,0) + nvl(:FUJ_LIVING,0)) * (v_lv_days_en_dt) / v_mon_days_en_dt; 

    v_tot: = nvl(v_tot_st_dt,0) + nvl(v_tot_en_dt,0);

    end if;

    Return round (v_tot);

    3. If the 3 months off, say date_start = 24-may-2014 date_end = July 2, 2014.

    I need some help here... what happens if the 4 month also leave...

    Please suggest.

    Kind regards

    Afzal.

    Hi Roger, Etbin

    Thanks for your replies.

    I found the solution on the month to display between two dates.

    To calculate that I used the loop as below

    declare

    ST DATE: =: date_start;--TO_DATE('24-MAY-2014','DD-MON-YYYY');

    ED DATE: =: date_end;--TO_DATE('02-JUL-2014','DD-MON-YYYY');

    number of v_t_amount;

    CURSOR C1 IS

    SELECT more GRAND (ST, ADD_MONTHS (TRUNC (st, 'MONTH'), (LEVEL - 1))) dt.

    LESS (ed,

    LAST_DAY (ADD_MONTHS (TRUNC (st, 'MONTH'), (LEVEL - 1)))

    ) ld

    OF THE DOUBLE

    CONNECT BY LEVEL<>

    MONTHS_BETWEEN (TRUNC (ed, 'MONTH'), TRUNC (st, 'MONTH'))

    + 1

    ORDER BY 1;

    V_AMOUNT NUMBER: = 0;

    V_T_AMOUNT NUMBER: = 0;

    NUMBER OF V_DAYS;

    BEGIN

    FOR I IN C1 LOOP

    V_AMOUNT: = (nvl(:SALARY_DIFF,0) + nvl(:SPECIAL_ALLOWANCE,0) + nvl(:CF_OTHERS,0)

    + NVL(:Computer,0) + nvl(:PHONE_ALLOW,0) + nvl(:WORK_NATURAL,0)

    (+ nvl(:TRANSPORTATION,0) * (i.1d - i.dt + 1) / TO_CHAR (LAST_DAY (i.1d), 'dd'));

    V_T_AMOUNT: = V_AMOUNT;

    end loop;

    end if;

    dbms_output.put_line (v_t_amount);

    end;

  • calculate the days remaining until a given date

    Hello

    I am facing a problem and can not find a good solution.

    I want to calculate how many days there are still up to a certain date.

    It is because I want to build in a callback to the re-kalibrate hardware which is used every year.

    So if it's today 05/11/2012, and the constant is 21/05/2012 labview must calculate there are still 10 days left before the re-kalibration must be finished.

    Someone has any idea how to do this?

    Thanks in advantage!

    of course, don't forget that time stamps are DBL in seconds.

    Hope this helps

  • How to calculate the days with 2 Date/time fields

    Hello
    I tried to create a workflow to update a numeric field with the following formula, however, I get an error message "value too long for the field 'ZNum_0' (maximum size 16) (SBL-DAT-00235). Can I know what is the problem with my calculation?

    dtCloseDate - dtAssignDate

    Thank you

    Hi, your formula is correct.

    You could be facing this problem because it will assess the value in decimal and result has no set limit for the decimal point. As digital field accept only 16 characters, the problem is occure.

    You must truncate the result with a defined decimal.

    Hope this will help you
    Dinesh

  • How to calculate the n prorations retained earnings

    When I am trying to enter code allocation House fast proration formula it gives me error. This same code works very well with the base salary only FF but with room allowance and other allowances n deducitons its gives me the following error: -.
    -------------------------------------------------------------------------------------------------------------
    APP-FF-33065: line 68: only the data base of points or input variables can be missed.

    Cause: You specified an item to be in default, which is not an element of database or an input variable.

    Action: Use an input variable or database in the default statement. If you want to change the value of a local variable, simply assign a value to it. You can change the global variable values using the form to handle Globals.
    ------------------------------------------------------------------------------------------------------------
    Now, the line 68 refers to the next line that I gave to my quick formula:

    IF (prorate_start did not fail) then
    (
    l_days = days_between (prorate_end, prorate_start) + 1
    day_in_Month = days_between (PAY_PROC_PERIOD_END_DATE, PAY_PROC_PERIOD_START_DATE) + 1
    House_allowance = (House_allowance * l_days) / day_in_Month
    House_allowance = (House_allowance)
    House_allowance2 = (House_allowance)
    House_allowance_tzs =(House_allowance*EXCHANGE_RATE1)
    )

    Please note that the folloing was referred to as a default value in the FF:

    the default for prorate_end is January 1, 1900 "(date)
    the default for prorate_start is January 1, 1900 "(date)
    default value for PAY_PROC_PERIOD_END_DATE IS 1 January 1950 ' (date)
    default value for PAY_PROC_PERIOD_START_DATE IS 1 January 1950 ' (date)

    I am trying to calculate the employee's salary n deductions based on the number of days the employee has worked.

    Please help/help me!

    I guess you need to add 'prorate_start' to the part "entries are" your quick formula. Same of course for the prorate_end (date).

  • Calculation of the days of working in a function

    I have a function that will count the total number of days between two weeks. That is, May 19, 2010 to June 18, 2010 is 30 total days in my cycle. We do not work on weekend so that 30 days is not correct. The formula below is how I calculate the days between cycles. Is it possible to not counting the weekend in my cycle? Please see the formula below:

    TIMESTAMPDIFF (SQL_TSI_DAY, "Free Dim". "Release cycle Start Date ', 'Release Sun'." Output cycle end Date")

    You should subtract the start end date date, divide by 7 and multiply by 5.

    Try with it.

    Concerning

  • calculate the time in seconds, the day of the year and year

    I have a data file where they record three columns, the seconds elapsed since midnight, day of the year and the year.  I am creating a timestamp of LabVIEW from these three numbers.  Of seconds elapsed since midnight, I can create seconds, minutes and hours.  If I feed in a cluster of time with the day of the year and the year, the timestamp of output is 0.  Does not work.  Although an input of the day of the year element, the Date and time with seconds function apparently requires day for months and months to work.

    The only solution I can imagine at this stage is to calculate the month and the day of the day of the year, which would imply a choice of the month table and a check of the leap year.

    Smart solutions, I'm missing?

    DaveT

    Dave,

    I found a Julian Georgian so far.

  • Calculate the number of days remaining until the next anniversary. Help, please!

    Hi guys,.

    I'm new to the forum and to the development of BB. So please do not judge harshly if the answer to my question seems obvious.

    I need to calculate the number of days until the next birthday (taking into account any valid birth date)

    After looking at the API and the forum search, I realized that I could

    calculate the difference between two dates in milliseconds and then divide the delta of the value of a day in milliseconds. That is to say:

    birthdayCalendar.set (Calendar.YEAR, those);

    Date1 = birthdayCalendar.getTime () .getTime ();

    date2 = System.currentTimeMillis ();

    Delta = date1 - date2

    numOfDays = delta\DateTimeUtilities.ONEDAY

    Here's my question. How do I create a valid date1 what about leap years?

    Maybe there's a better way to solve this problem?

    Any help is greatly appreciated.

    I agree that the determination of the number of days between today and Feb. 29 could be a little difficult, if it is not a leap year.  I suspect that the calendar has a certain built-in mechanism to compensate for this, but your solution to choose a date is better.

    DST has a role to play, and Yes, the calendar makes up for it.  Let us take two dates, for example (before DST) March 1 and June 1 (after the DST).  If you take a calendar and set the same hour, minute, etc., they are all the same except for dates, then subtract one from the other, and then divide by the number of milliseconds in 1 hour, you calculate the number of hours between the same time on two different days.  You will find that it is not a multiple of 24 hours - because there is actually an hour less than the number of days since the clocks move forward (in the northern hemisphere anyway...),

    In your case, you are not calculating the number of hours, you calculate the number of days.  But you will be dividing by [24 * (time in an hour)].  If you take [23 * (time in an hour)] and divide it by [24 * (time in an hour)], using arithmetic on integers, you will end up 0.  The easiest to get around this, who also works for the end of the DST too, is to simply add one hour to the date before the division.

    Hope that makes sense...

  • How to calculate the first day of the month following in BI Publisher

    I need to be able to calculate the first day of the month of a date field in a BI Publisher model. The field name is COL_CLM_180 and contains a date in the format "YYYY-MM-DD". I have found so far any documentation that still gives me an idea of what to do.

    Any help or advice would be appreciated

    Hi - thank you very much for your help. Your last answer got me going in the right direction and I indeed was dense. I don't know why I don't think to the calculation in the original query. I put the statement: TRUNC (ADD_MONTHS(A.COL_CLM_180,1), 'MM') in a column in the query of conduct and it has worked flawlessly. Thank you - thank you - thank you.

  • Calculate the hours between 2 business days

    Hi all

    Do a complex calculation on the days I do not know how to achieve this.

    Here is my case:

    I have a week of work with hours of work.

    Then there's this delivery time sheet for how long should be set an order ready to be delivered:

    Order1: max 5 hours of work

    Order2: max 8 working hours

    Order3: max 16 hours of work

    When an order is placed, the time of the order is recorded, and when an order has been set in ready to be delivered, this time is also registered.

    How to calculate the time difference between the time where an order has been placed and the time where the order has been on loan. Thereby also taking into account the working days and hours of work.

    Example: type order1 order was placed Tuesday at 15:00.

    Order has been fixed loan Wednesday at 14:00

    This means that to fix this ready order lasts 7 hours, which means that it is 2 hours time.

    CREATE TABLE REF_WORKDAYS
      (
        
        "WERKDAG"       VARCHAR2(15 ) NOT NULL ENABLE,
        "SOORT_WERKDAG" VARCHAR2(15 ) NOT NULL ENABLE,
        "BEGIN_TIJD"    VARCHAR2(10 ) NOT NULL ENABLE,
        "EIND_TIJD"     VARCHAR2(10 B) NOT NULL ENABLE,
        
      )
    

    Insert into REF_WORKDAYS (WERKDAG,SOORT_WERKDAG,BEGIN_TIJD,EIND_TIJD) values ('Monday','WORKINGDAY','08:00','16:00');
    Insert into REF_WORKDAYS (WERKDAG,SOORT_WERKDAG,BEGIN_TIJD,EIND_TIJD) values ('Tuesday','WORKINGDAY','08:00','16:00');
    Insert into REF_WORKDAYS (WERKDAG,SOORT_WERKDAG,BEGIN_TIJD,EIND_TIJD) values ('Wednesday','WORKINGDAY','08:00','16:00');
    Insert into REF_WORKDAYS (WERKDAG,SOORT_WERKDAG,BEGIN_TIJD,EIND_TIJD) values ('Thursday','WORKINGDAY','08:00','16:00');
    Insert into REF_WORKDAYS (WERKDAG,SOORT_WERKDAG,BEGIN_TIJD,EIND_TIJD) values ('Friday','WORKINGDAY','08:00','16:00');
    Insert into REF_WORKDAYS (WERKDAG,SOORT_WERKDAG,BEGIN_TIJD,EIND_TIJD) values ('Satrurday','WORKINGDAY','08:00','14:00');
    Insert into REF_WORKDAYS (WERKDAG,SOORT_WERKDAG,BEGIN_TIJD,EIND_TIJD) values ('Sunday','NOT-WORKINGDAY','08:00','16:00');
    
    COMMIT;
    

    create table glas_order
    
    (order_id number
    , order_desc varchar2(100) not null
    , order_type varchar2(10) not null
    , order_date date not null
    , order_ready date
    
    );
    

    Insert into GLAS_ORDER (ORDER_ID,ORDER_DESC,ORDER_TYPE,ORDER_DATE,ORDER_READY) values (1,'order bla','Order1',to_date('07-APR-15 09:00','DD-MON-RR HH24:MI'),to_date('08-APR-15 12:00','DD-MON-RR HH24:MI'));
    Insert into GLAS_ORDER (ORDER_ID,ORDER_DESC,ORDER_TYPE,ORDER_DATE,ORDER_READY) values (2,'order nice','Order1',to_date('14-APR-15 10:00','DD-MON-RR HH24:MI'),to_date('16-APR-15 16:00','DD-MON-RR HH24:MI'));
    Insert into GLAS_ORDER (ORDER_ID,ORDER_DESC,ORDER_TYPE,ORDER_DATE,ORDER_READY) values (3,'order ugly','Order2',to_date('18-APR-15 13:00','DD-MON-RR HH24:MI'),to_date('21-APR-15 09:00','DD-MON-RR HH24:MI'));
    
    COMMIT;
    

    Thank you

    Diana

    Select

    I like order_id

    such as length d

    order_type

    d decode(order_type,'Order1',5,'Order2',8)

    overtime

    of glas_order o

    model

    Reference r on

    (select

    WERKDAG w

    begin_tijd b

    e eind_tijd

    , (to_date (eind_tijd, 'HH24') - to_date (begin_tijd, 'HH24')) * 24 hard

    of ref_workdays

    where soort_werkdag = "WORKINGDAY")

    dimension (w)

    measures (b, e, hard)

    main m

    partition of (order_id I)

    size of (0 n)

    measures (0d, order_date, order_ready, cast (null as varchar2 (10)) as wday, order_type)

    iterate (1e6) rules until (iteration_number > = trunc(order_ready[0]) - trunc(order_date[0])))

    WDAY [0] = to_char (order_date [0] + iteration_number, 'FMDay', 'NLS_DATE_LANGUAGE = ENGLISH')

    , d [0] = d [0] +.

    case

    When trunc(order_date[0]) = trunc(order_ready[0]) - beginning and ready same day

    then presentv (r.b [wday [0]],)

    less (largest (order_ready [0], to_date (to_char (order_date [0], 'YYYYMMDD') | r.b [WDAY [0]], 'YYYYMMDDHH24:MI')), to_date (to_char (order_date [0], 'YYYYMMDD') | r.e [WDAY [0]],'YYYYMMDDHH24:mi'))))

    -bigger (to_date (to_char (order_date [0], 'YYYYMMDD') | r.b [WDAY [0]], 'YYYYMMDDHH24:MI'), least (order_date [0], to_date (to_char (order_date [0], 'YYYYMMDD') | r.e [WDAY [0]],'YYYYMMDDHH24:mi'))))))

    0) * 24

    When order_date [0] + iteration_number = order_date [0] - first day

    then presentv (r.b [wday [0]],)

    TO_DATE (to_char (order_date [0], 'YYYYMMDD') | r.e [WDAY [0]], 'YYYYMMDDHH24:MI')

    -bigger (order_date [0], to_date (to_char (order_date [0], 'YYYYMMDD') | r.b [WDAY [0]],'YYYYMMDDHH24:mi'))))

    0) * 24

    When trunc(order_date[0]) + iteration_number = trunc(order_ready[0]) - last day

    then presentv (r.b [wday [0]],)

    less (order_ready [0], to_date (to_char (order_ready [0], 'YYYYMMDD') | r.e [WDAY [0]],'YYYYMMDDHH24:mi'))))

    -to_date (to_char (order_ready [0], 'YYYYMMDD') | r.b [WDAY [0]], 'YYYYMMDDHH24:MI')

    0) * 24

    of another nvl (r.dur [wday [0]], 0)

    end

    )

    ORDER_ID DURATION ORDER_TYPE OVERTIME
    1 11 Order1 6
    2 22 Order1 17
    3 10 Order2 2

    Rewrittten party rules for readability purposes (more resources)

    measures (0d, order_date, order_ready, cast (null as varchar2 (10)) as to_date (null), (null) to_date, bd, order_type, wday ed)

    iterate (1e6) rules until (iteration_number > = trunc(order_ready[0]) - trunc(order_date[0])))

    WDAY [0] = to_char (order_date [0] + iteration_number, 'FMDay', 'NLS_DATE_LANGUAGE = ENGLISH')

    , comics [0] = to_date (to_char (order_date [0] + iteration_number, 'YYYYMMDD') | r.b [WDAY [0]], 'YYYYMMDDHH24:MI')

    , ed [0] = to_date (to_char (order_date [0] + iteration_number, 'YYYYMMDD') | r.e [WDAY [0]], 'YYYYMMDDHH24:MI')

    , d [0] = d [0] +.

    case

    When trunc(order_date[0]) = trunc(order_ready[0]) - beginning and ready same day

    then presentv (r.b [wday [0]],)

    less (largest (order_ready [0], [0] bd), ed [0])

    -Greatest (BD [0], least(ORDER_DATE[0],ED[0]))

    0) * 24

    When order_date [0] + iteration_number = order_date [0] - first day

    then presentv (r.b [wday [0]],)

    ED [0]

    -Greatest(ORDER_DATE[0],BD[0])

    0) * 24

    When trunc(order_date[0]) + iteration_number = trunc(order_ready[0]) - last day

    then presentv (r.b [wday [0]],)

    least(order_ready[0],ED[0])

    -bd [0]

    0) * 24

    of another nvl (r.dur [wday [0]], 0)

    end

    )

    Jubilee should be Saturday I guessed.

  • PL/SQL function to calculate the non-working days

    Hello

    I have the following pl/sql function which generates a number of days between two selected dates (i.e. excluding weekends). However, I also need to exclude specific holidays - day of Christmas etc. These holiday dates are stored in a table in our database (11 GR 2) called "HOLIDAY".

    How can I integrate the holidays which is held in the table of holidays in the following query to exclude these dates as well? I know how to write a separate funtion pl/sql for a number of days between two dates using SELECT... BUT I can't work out how to bring together them in a single query.

    Could someone show me how with the pl/sql / dates below please?

    Example of HOLIDAY table below.

    Thank you!

    TP

    create or replace
    function WORKING_DAYS (pi_start_date in date, pi_end_date in date) return integer
    
    is
    
    v_start_date date :=pi_start_date;
    v_end_date date:=pi_end_date;
    v_count integer:=0;
    
    begin
    
    while v_start_date <= v_end_date
          loop
                            if to_char(v_start_date,'D') not in ('6','7')                    
                            then
                            v_count := v_count+1;                       
                            end if;
                           
                    v_start_date:=v_start_date+1;
                   
          end loop;
         
    return v_count;
    
    end;
    
    

    (select '10-Apr-2013' as NWD from dual union all
    select '06-May-2013' from dual union all
    select '27-May-2013' from dual union all
    select '26-Aug-2013' from dual union all
    select '26-Dec-2013' from dual union all
    select '25-Dec-2013' from dual union all
    select '01-Jan-2014' from dual union all
    select '18-Apr-2014' from dual union all
    select '21-Apr-2014' from dual union all
    select '05-May-2014' from dual union all
    select '26-May-2014' from dual union all
    select '25-Aug-2014' from dual union all
    select '25-Dec-2014' from dual union all
    select '26-Dec-2014' from dual) HOLIDAYS
    

    Hello

    the link is on MOSC, not OTN... Here's a copy:

    This function calculates the number of days between two dates, ignoring weekends and holidays (if requested and if the holidays are stored in a table)

    I give an example of table 'public_holiday' with sample data, but users must ensure that their table contains the relevant data (all holidays within the maximum range of use of the service)

    CREATE TABLE public_holiday (calendar_day, DATE, text VARCHAR2 (30));

    FUNCTION to CREATE or REPLACE nb_days (p_date_from IN DATE

    p_date_to DATE by DEFAULT TRUNC (sysdate)

    , p_public_holidays in CHAR DEFAULT 'Y '.

    ) RETURN NUMBER

    DEFINE AUTHID

    AS

    /*********************************************************************/

    / * Author: Bruno Vroman * /.

    / * Created: 23-AUG-2012 * /.

    / * Last updated: 23-AUG-2012 * /.

    / * Object: to calculate the number of days between 2 dates, to the exclusion of * /.

    / * Saturday and Sunday, but also "holidays" If the * /.

    / * argument 'p_public_holidays' = 'Y ' * /.

    / * Support: p_date_from<= p_date_to                             ="">

    / * component ' hour min dry "ignored (just counting days) * /.

    /* First step:                                                       */

    / * the calendar days between 2 days * /.

    / Remove 2 days for each "week" and 0 or 1 extra day * /.

    / * function to a condition "complex" mix day of first week * /.

    / * and the number of days when full remaining weeks are removed * /.

    / * (set up once for all, for example if there is 3 days and the * /)

    (/ * first day is a Thursday, there is 1 "Sat/Sun" to subtract) * /.

    / * Second step: If 'p_public_holidays' = 'Y': other * /.

    / * days, do not count holidays.                         */

    / Holiday everyday are defined in a table "public_holiday" * /.

    / * Note: there may be holidays defined on Saturday/Sunday.       */

    /*********************************************************************/

    l_result NUMBER;

    l_from DATE;

    l_to DATE;

    l_case tank (4);

    BEGIN

    l_from: = TRUNC (p_date_from);

    l_to: = TRUNC (p_date_to);

    l_case: = TO_CHAR (l_from, 'Dy', 'NLS_DATE_LANGUAGE = English').

    To_char (MOD (l_to - l_from + 1, 7));

    l_result: = l_to - l_from + 1

    -TRUNC ((l_to-l_from + 1) / 7) * 2

    -CASE

    WHEN l_case IN ('Mon6', 'Tue5', 'Wed4', 'Thu3', 'Fri2'

    , "Sat1", "Sun1", "Sun2', 'Sun3", "Sun4".

    , "Sun5', 'Sun6.

    )

    THEN 1

    WHEN l_case IN ('Tue6', 'Wed5', 'Wed6', 'Thu4', "Thu5"

    , 'Thu6', 'Fri3', 'Fri4', 'Fri5', 'Fri6 '.

    , "Sat2", "Sat3', 'Sat4', 'Sat5", "Sat6.

    )

    THEN 2

    0 OTHERWISE

    END

    ;

    IF SUPERIOR (p_public_holidays) = "Y".

    THEN

    SELECT l_result - COUNT (*)

    IN l_result

    OF public_holiday p

    WHERE p.calendar_day > = l_from

    AND p.calendar_day<=>

    AND SUBSTR (TO_CHAR (p.calendar_day

    , "Dy".

    'NLS_DATE_LANGUAGE = English'

    )

    , 1, 1 ) != 'S'

    ;

    END IF;

    RETURN l_result;

    EXCEPTION

    WHILE OTHERS

    THEN

    DBMS_OUTPUT. Put_line (' CTF nb_days (' |))

    To_char (p_date_from, "MON-DD-YYYY"). ', ' ||

    To_char (p_date_to, "MON-DD-YYYY"). ', ' ||

    p_public_holidays | ' ) : ' || SQLERRM

    );

    LIFT;

    END nb_days;

    /

    REM

    REM example:

    REM A) fill out the 'public_holidays '.

    REM

    TRUNCATE TABLE public_holiday;

    INSERT INTO public_holiday VALUES (DATE ' 2012-01-01', ' new year (a Sunday)');

    INSERT INTO public_holiday VALUES (DATE '' 2012-01-03, "for example");

    REM (insert other days...)

    COMMIT;

    Call the function for some pairs of dates of REM B)

    REM nb1: remove only Sat/Sun

    REM nb2: also remove holidays

    REM

    ALTER SESSION SET nls_date_format ='Dy DD-MON-YY';

    WITH some_dates AS

    (SELECT DATE ' 2011-12-29'd dual FROM

    UNION ALL SELECT DATE ' 2012-01-08' FROM dual

    UNION ALL SELECT DATE ' 2012-01-10' FROM dual

    )

    SELECT d1.d 'FROM '.

    , d2.d ' to THE '.

    , nb_days (d1.d, d2.d, ' don't) nb1

    , nb_days (d1.d, d2.d, 'Y') nb2

    OF some_dates d1

    some_dates d2

    WHERE d1.d<=>

    ORDER BY nb1, nb2, d1.d

    ;

    GO TO NB1 NB2

    ------------- ------------- ---- ----

    Monday, January 8, 12 Monday, January 8, 12 0 0

    Friday, December 29, 11 Friday, December 29, 11 1 1

    Wednesday, January 10, 12 Wednesday, January 10, 12 1 1

    Monday, January 8, 12 Wednesday, January 10, 12 2 2

    Friday, December 29, 11 Monday, January 8, 12 7 6

    Friday, December 29, 11 Wednesday, January 10, 12 9 8

    Hope that this could be useful, but note that this code has not been completely tested, so check and test before you trust it (in the case of any questions, please post a comment)

    Bruno Vroman.

    Best regards

    Bruno

  • Calculate the number of days off weekends


    Hi all

    I have a requirement where I have to calculate the difference between two dates, excluding weekends and holidays. Is there a way I can do it in OBIEE analysis.

    Any help would be appreciated.

    Thanks in advance!

    Check it for weekends cool - bi.com

    For the holidays, you will need to customize you the size of the day

    check if help

  • How to calculate the number of days/weeks/months between 2 dates?

    Hello

    I would like to know how to calculate the number of days/weeks/months between 2 dates in OBIEE 11 g, for example, I have 26/05/2013 and 19/05/2013, then I want to get 7 days.

    Thank you!
    Jamie

    Hi Jamie,

    Through this links...

    http://www.bravesoft.com/blog/?p=682
    http://twobiee.blogspot.in/2012/01/working-with-date-differences.html

    Mark as correct it allows u...
    Thank you...

Maybe you are looking for