Count the hours between the times of the day

Hello

It is a timesheet, calculation of payment:

I'm trying to find a way to calculate how many hours is between two specific times of the day.

I enter a start time and an end time (in 2 different items), I calculate the number of hours that is. What I can understand.

Then I need to know how many hours is between 16:00 and 22:00.

The reason is that there is an additional extra payment for those hours.

So: "payment on time' X ' total hours work in a day ' + 'bonus' X ' hours between 16 and 22" = "total wages for a day" "»

Thank you

Enter the full date and time in columns A and B (for example ' 12 Sep 2016 8:00 AM "or you like the what ever valid date time value):

C2 = B2−A2

D2 = C2−DURATION (0, 0, 24 × MAX (TIMEVALUE "(04:00 PM)") −TIMEVALUE (A2), 0)) −DURATION (0, 0, 24 × MAX (TIMEVALUE (B2) −TIMEVALUE (' 22:00 "" "), 0))

Select cells C2 and D2, copy

Select cells C2 at the end of column D, dough

If you prefer the values in column D as decimal hours use the formula:

dur2hours (D2)

or replace the formula earlier as follows:

D2 = dur2hours (C2−DURATION (0, 0, 24 × MAX (TEMPSVAL ("04:00 PM") −TIMEVALUE (A2), 0)) −DURATION (0, 0, 24 × MAX (TIMEVALUE (B2) −TIMEVALUE (' 22:00 "" "), 0)))

Tags: iWork

Similar Questions

  • Count the days back by year and month?

    In my doc, I have 7 text fields (Sun, Mon, Mar, sea, game, Fri, SAT). I use another field enter a date. When I enter an end date, I have 7 fields to be filled with dates. For example, if I enter the date field 06 18, 2016, I wish I had the 7 fields like this, Sun would show 12, Lun would show 13, AUT show 14, sea would indicate 15, game show 16, Fri would show 17 and Sam would have 18. I'm counting the days is backwards because I'm coming the weekend of date (always a Saturday).

    What I'm running is the month before sometimes will have 30 days, some months have 31 (and of course leap years). Thus, for example, if I choose 2 July 2016 days should come back like that, Sun should see 26, LUNs should show 27, Tue should show 28, sea should show 29, that game should show 30, Fri should show 01, Sam should show July 02.

    How can I do this correctly? I need a javascript smart thing to do. Can someone please help me with an example? Thank you.

    Here is a link to a sample form that shows how you can do this: http://acroscript.net/pdf/demos/populateWeek.pdf

    The script is located in the field Validate event entry date. Note that day fields use a special naming convention that allows a simplification of the code, so you have to use a similar model.

  • difference in hours between two time zones of differnet

    I have a sysdate (EAST) and a function util_pkg.local_tz returns a different datetime value.
    I need to get the difference in hours between sysdate and another date.

    Select sysdate, util_pkg.local_tz (sysdate, ' Asia/Seoul') of double;

    18/05/2011 11:15:00.000000000 FROM 18/05/2011 10:15 PM + 09:00

    Quest:-find the difference in hours between these two date and then add the difference of hours + sysdate

    FUNCTION local_tz (p_datetime IN TIMESTAMP,
                          p_timezone IN VARCHAR2)
          RETURN TIMESTAMP WITH TIME ZONE
       AS
       BEGIN
          RETURN FROM_TZ(p_datetime, TZ_OFFSET(con_database_timezone))
                         AT TIME ZONE TZ_OFFSET(p_timezone);
       END local_tz;

    When you calculate the diff between TIMESTAMP WITH TZ they both are converted to time UTC (in fact they are stored as UTC). So diff between SYSTIMESTAMP in EST and SYSTIMESTAMP in Seoul will always be 0, as bioth are "now". You need to cast TIMESTAMP WITH TZ 'losing' time zone timestamp:

    SQL> select cast(systimestamp at time zone 'Asia/Seoul' as timestamp) - systimestamp from dual;
    
    CAST(SYSTIMESTAMPATTIMEZONE'ASIA/SEOUL'ASTIMESTAMP)-SYSTIMESTAMP
    ---------------------------------------------------------------------------
    +000000000 13:00:00.000000
    
    SQL>  
    

    SY.

  • How to find the hours between two times

    Hai All

    I had a problem I need to calculate work time

    For example

    Respondent outtime

    0815 1715

    So I need to calculate a time between these two times

    How can I do using function for 100 our

    Concerning

    Srikkanth.M

    Hello

    use the below the update statement.

    update dail_att set wtime =  extract(hour from (to_date(outtime,'HH24:MI')-to_date(intime,'HH24MI')) day to second);
    

    Solution of the sample...

    PRAZY@11gR1> desc dte;
     Name            Null?    Type
     ------------------- -------- --------
     INTIME           VARCHAR2(4)
     OUTTIME        VARCHAR2(4)
     HRS                NUMBER
    
    PRAZY@11gR1> select * from dte;
    
    INTIME     OUTTIME           HRS
    ---------- ---------- ----------
    0815       1715
    0900       1800
    0830       1630
    
    Elapsed: 00:00:00.00
    PRAZY@11gR1> update dte set hrs = extract(hour from(to_date(outtime,'HH24MI')-to_date(intime,'HH24MI')) day to second);
    
    3 rows updated.
    
    Elapsed: 00:00:00.01
    PRAZY@11gR1> select * from dte;
    
    INTIME     OUTTIME           HRS
    ---------- ---------- ----------
    0815       1715                9
    0900       1800                9
    0830       1630                8
    
    Elapsed: 00:00:00.00
    

    Kind regards
    Prazy

    Published by: Prazy on March 24, 2010 12:43

  • counting the days between two dates

    I have 3 columns in my table

    date of purchase date sold days
    computer 24 April 09-11 May 09


    How can I write that a sql statement will help me to create a new column days and days between date bought and sold


    Thank you

    872959 wrote:
    I have 3 columns in my table

    date of purchase date sold days
    computer 24 April 09-11 May 09

    How can I write that a sql statement will help me to create a new column days and days between date bought and sold

    Thank you

    just subtract two dates & the difference will be in units of days

    SQL > select to_date('11-MAY-09','DD-MON-YY') - double TO_DATE('24-APR-09','DD-MON-YY');

    TO_DATE('11-MAY-09','DD-MON-YY')-TO_DATE('24-APR-09','DD-MON-YY')
    -----------------------------------------------------------------
    17

    Published by: sb92075 on July 19, 2011 10:26

  • Count the days of Conesutive for the events occur?

    Hello I have a consecutive not time-based, but you need to keep track of the time.

    -data table
    with t as)
    Select 2001 W_ID, to_date('4-01-2013','mm-dd-yyyy') dt, D_Val (null) of all the double union
    Select 2001, to_date ('4-02-2013', ' mm-dd-yyyy'), (null) of all the double union
    Select 2001, to_date ('4-03-2013', ' mm-dd-yyyy'), (null) of all the double union
    Select 2001, to_date ('4-04-2013', ' mm-dd-yyyy'), (null) of all the double union
    Select 2001, to_date('4-05-2013','mm-dd-yyyy'), 53 Union double all the
    Select 2001, to_date('4-06-2013','mm-dd-yyyy'), (null) of all the double union
    Select 2001, to_date('4-07-2013','mm-dd-yyyy'), (null) of all the double union
    Select 2001, to_date('4-08-2013','mm-dd-yyyy'), (null) of all the double union
    Select 2001, to_date('4-09-2013','mm-dd-yyyy'), 53 Union double all the
    Select 2001, to_date('4-10-2013','mm-dd-yyyy'), 165 Union double all the
    Select 2001, to_date('4-11-2013','mm-dd-yyyy'), 165 Union double all the
    Select 2001, to_date('4-12-2013','mm-dd-yyyy'), (null) of all the double union
    Select 2001, to_date('4-13-2013','mm-dd-yyyy'), 165 Union double all the
    Select 2001, to_date('4-14-2013','mm-dd-yyyy'), 165 Union double all the
    Select 2004, to_date ('4-01-2013', ' mm-dd-yyyy'), (null) of all the double union
    Select 2004, to_date ('4-02-2013', ' mm-dd-yyyy'), (null) of all the double union
    Select 2004, to_date ('4-03-2013', ' mm-dd-yyyy'), (null) of all the double union
    Select 2004, to_date ('4-04-2013', ' mm-dd-yyyy'), (null) of all the double union
    Select 2004, to_date('4-05-2013','mm-dd-yyyy'), 53 Union double all the
    Select 2004, to_date('4-06-2013','mm-dd-yyyy'), (null) of all the double union
    Select 2004, to_date('4-07-2013','mm-dd-yyyy'), (null) of all the double union
    Select 2004, to_date('4-08-2013','mm-dd-yyyy'), (null) of all the double union
    Select 2004, to_date('4-09-2013','mm-dd-yyyy'), 53 Union double all the
    Select 2004, to_date('4-10-2013','mm-dd-yyyy'), 165 Union double all the
    Select 2004, to_date('4-11-2013','mm-dd-yyyy'), 165 Union double all the
    Select 2004, to_date('4-12-2013','mm-dd-yyyy'), 165 Union double all the
    Select 2004, to_date('4-13-2013','mm-dd-yyyy'), 165 Union double all the
    Select 2004, to_date('4-14-2013','mm-dd-yyyy'), 165 of the double
    )

    results should be present
    with t as)
    Select 2001 W_ID, to_date('4-01-2013','mm-dd-yyyy') dt, (null), D_Val, Lead_Lag of lead, 4 County, Count2 4, drive to Lead_Lag2 Union double all the
    Select 2001, to_date('4-02-2013','mm-dd-yyyy'), (null), Lag, 4, 4, union offset double all the
    Select 2001, to_date('4-03-2013','mm-dd-yyyy'), (null), Lag, 4, 4, union offset double all the
    Select 2001, to_date('4-04-2013','mm-dd-yyyy'), (null), Lag, 4, 4, union offset double all the
    Select 2001, to_date('4-05-2013','mm-dd-yyyy'), 53, the lead, 1, 1, lead all the double union
    Select 2001, to_date('4-06-2013','mm-dd-yyyy'), (null), lead, 3, 3, union lead double all the
    Select 2001, to_date('4-07-2013','mm-dd-yyyy'), (null), Lag, 3, 3, union offset double all the
    Select 2001, to_date('4-08-2013','mm-dd-yyyy'), (null), Lag, 3, 3, union offset double all the
    Select 2001, to_date('4-09-2013','mm-dd-yyyy'), 53, the lead, 1, 3, the lead of all the double union
    Select 2001, to_date('4-10-2013','mm-dd-yyyy'), 165, lead, 2, 3, Lag of union double all the
    Select 2001, to_date('4-11-2013','mm-dd-yyyy'), 165, Lag, 2, 3, union offset double all the
    Select 2001, to_date('4-12-2013','mm-dd-yyyy'), (null), lead, 1, 1, lead union double all the
    Select 2001, to_date('4-13-2013','mm-dd-yyyy'), 165, lead, 2, 2, lead all the double union
    Select 2001, to_date('4-14-2013','mm-dd-yyyy'), 165, Lag, 2, 2, union offset double all the
    Select 2004, to_date ('4-01-2013', ' mm-dd-yyyy'), (null), lead, 4, 4, lead Union double all the
    Select 2004, to_date('4-02-2013','mm-dd-yyyy'), (null), Lag, 4, 4, union offset double all the
    Select 2004, to_date('4-03-2013','mm-dd-yyyy'), (null), Lag, 4, 4, union offset double all the
    Select 2004, to_date('4-04-2013','mm-dd-yyyy'), (null), Lag, 4, 4, union offset double all the
    Select 2004, to_date('4-05-2013','mm-dd-yyyy'), 53, the lead, 1, 1, lead all the double union
    Select 2004, to_date('4-06-2013','mm-dd-yyyy'), (null), lead, 3, 3, union lead double all the
    Select 2004, to_date('4-07-2013','mm-dd-yyyy'), (null), Lag, 3, 3, union offset double all the
    Select 2004, to_date('4-08-2013','mm-dd-yyyy'), (null), Lag, 3, 3, union offset double all the
    Select 2004, to_date('4-09-2013','mm-dd-yyyy'), 53, the lead, 1, 6, execution of all the double union
    Select 2004, to_date('4-10-2013','mm-dd-yyyy'), 165, lead, 5, 6, Lag of union double all the
    Select 2004, to_date('4-11-2013','mm-dd-yyyy'), 165, Lag, 5, 6, union offset double all the
    Select 2004, to_date('4-12-2013','mm-dd-yyyy'), 165, Lag, 5, 6, union offset double all the
    Select 2004, to_date('4-13-2013','mm-dd-yyyy'), 165, Lag, 5, 6, union offset double all the
    Select 2004, to_date('4-14-2013','mm-dd-yyyy'), 165, Lag, 5, 6, the double shift
    )

    Here's the basic scheme

    with got_group_id as
    (
    Select *.
    W_ID,
    DT
    case
    When lag (dt) over (partition by W_ID order by dt) plus 1 is equal to dt
    then "Lag".
    When lead (dt) over (partition by W_ID order by dt) dt =-1
    then "Lead."
    else 'no '.
    end Lead_Lag,

    D_Val - row_number () over (partition by W_ID order by dt) as group_id,
    D_Val

    t
    "where dt between 1 April 2013 ' and 14 April 2013"
    order of W_ID, dt asc

    )

    Select *.
    Of
    (
    Select
    got_group_id.*,
    Count (*) over (partition W_ID, group_id) County
    of got_group_id
    )
    where count > = 1
    order of W_ID,
    ASC DT
    ;


    Any thoughts?

    I use:
    Oracle SQL Developer (3.0.04)
    Build HAND - 04.34

    found data with several d_val for the same date.

  • Y at - it a gadget or a widget or app or something that I could add to my office that counts the days since an event?

    For example. 11 days since the last accident, 453 days since the last soda consumed, etc. Running Windows 7.

    Do a Google search for: -.

    counter of days for windows 7

    and make your choice

  • Calculate elapsed hours between two time fields

    I have a form with fields TimeStart and TimeEnd. Both are formatted as field time in the format hh: mm tt. I also have a field called hours with the number format. Here is the Javascript code that I have in the section calculation Script custom field hours. Could someone tell me why it doesn't work? This script started as a date calculation script (work), and I changed to the calculation of hours instead of days.

    var strStart = this.getField("TimeStart").value;

    var strEnd = this.getField("TimeEnd").value;

    If (strStart.length & & strEnd.length)

    {

    var timeStart = util.scand ("h: mm tt", strStart);

    var timeEnd = util.scand ("h: mm tt", strEnd);

    diff var = timeEnd.getTime () - timeStart.getTime ();

    var hour = 60 * 60 * 1000;

    var h = Math.floor (diff/oneHour);

    Event.Value = hours;

    }

    of another event.value = 0;

    The order for the calculation of the fields is wrong, you need to update.

  • Count the number of hours between the dates off holiday/weekend

    Hi all

    I've not worked with dates and was recently asked to create a report where I am looking for the number of hours between two dates only count business days.

    So for example I have given as follows

    Created on 2011-03-30 15:00
    Treaty of 2011-03-30 15:03:46
    Filled 2011-04-01 17:25:02
    Posted 2011-04-01 17:45

    For a total of looking for the CREATION and dates

    50 hours and 45 minutes

    IM also trying to exclude weekends and holidays, I read around and was able to also find an array of dates where I main date, the HOLIDAY_IND column, and the column WEEKDAY_IND

    If the calendar table I have looks like

    CALENDER_DATE HOLIDAY_IND WEEKDAY_IND
    2011-03-31 YY
    2011-04-01 N Y
    2011-04-02 N N

    IM really very puzzled to know where to start

    I thought I'd try to write with PL/SQL, but I don't have access of the user to create procedures/functions, so looks like right up to SQL

    Any help is appreciated!

    Hello

    Depeneding on your data and your needs, you can do something like this:

    SELECT     created_DATE,
    ,     mailed_date
    ,     24 * ( (mailed_date - created_date)
              - (
                SELECT  COUNT (*)
                FROM        table_o_dates
                WHERE    main_date > created_date
                AND        main_date < TRUNC (mailed_date)
                AND        (   holiday_ind = 'Y'
                         OR  weekday_ind = 'N'
                      )
              )
               )               AS hours_between
    FROM     table_x
    ;
    

    I hope that answers your question.
    If not, post a small example of data (CREATE TABLE and only relevant columns, INSERT statements) for all tables and also post the results desired from these data.
    Explain, using specific examples, how you get these results from these data.
    Always tell what version of Oracle you are using.

    What do you do if created_date or mailed_date is not a working day? Examples in you data and results.

  • The time in the calendar works with an hour between start and end time

    Until recently, calendar worked OK but now only allow me to have a time of an event if I try to put the first gestures of time within an hour of arrival times longer.

    There is a symbol link to the right of the time of departure and arrival. If the points are in contact with the time interval that you have in the calendar (by default 60 minutes) options will be kept when you change the time. Click on this symbol, and the points will be away and stop this action.

  • Calculate the hours between two dates

    Hello

    I have a requirement to count the hours with 2 given timestamps, something like:
    SQL> select ((to_date('22-oct-2012 13:00:00','dd-mon-yyyy hh24:mi:ss') - to_date('20-oct-2012 13:00:00','dd-mon-yyyy hh24:mi:ss'))*24) B from dual ;
    
             B
    ----------
            48
    However, I wish it would be that simple. I just need to count the hours between two timestamps for the hours of work for example, 08:00 - 17:00, MONDAY to Friday (excluding weekends).
    So lets say I have to count the hours between two dates above the result should be 18 hours not 48 (4 hours on 20/oct, 9 hours on 21/oct to 5 hours 22/oct).
    How can I achieve this? Any idea will be useful.

    Thank you

    My query generates a list of all the hours between the start and end time, filters on the hours that are outside of the hours of work and then account for the remaining lines. Change that to partial hours must just be a case of replace the two occurrences of 1/24 with 24/01/60, then - as say you - Division COUNT (*) by 60.

    There may be performance issues using techniques of generation of line like this, if you put this in a query involving the joining of several lines of other tables (for example where the dates of beginning and end are derived from several employees?) or in several days. If you don't find it then count the number of whole days (taking weekends into account) between dates and work on the partial days after that it could be better. This would probably involve a lot of statements of case (which I don't have time to test it now).

    Ben

  • How to calculate the hours between two dates by the numbers

    If I update 09:00 start time 17:00 end time of shift in C3 and B3, how to use a D3 formula to calculate the number of hours between the two?  Then I can just copy down the lines for nth years...

    It is a spreadsheet of the part-time staff payroll.

    I'm sure that a lot of people out there have done that.

    Help, please.

    Thank you.

    Eddie

    What program of worksheet that you are using? Since you have a newer iMac running El Capitan, I can safely assume that you use NOT AppleWorks, which is a Power PC application that can run on any OS newer than the snow leopard, OS X 10.6.8.

    If you use numbers, try to repost your question in numbers for Mac forum. If you use Microsoft Excel, try posting in the Microsoft forums. LibreOffice also has community support.

  • How to count the time exactly?

    I tried to count the time using a VI like the one attached.

    It's that's not couting correctly. There is a possible reason, I have observed.

    The computer isn't able to handle the VI as soon as necessary.

    I thought about this because, when in edit mode the time count was very bad, and, when I created an application and installed, it ran okay, how 'light '. But today, when I tried to use this application with an old computer it did not work. The clock is slow.

    Is it possible to count the time correctly?

    I use a DAQ6009 to make my works, my VI is big enough and I need one iteration to each 1 ms (milliseconds) as I am with digital inputs from 5 events of coders (I know that's not the right way to count the encoders, but it's the only way I can do it, and it works).

    Thank you in advace! I hope you can help me!

    Hugs!

    Ok.  I will try to help you understand certain things.

    The number of cycles and wait (and wait until the next ms Multiple) functions all use a 1 kHz derived from the clock of the processor clock. The accuracy of these clocks is not large, although they are probably similar to the precision of the stopwatch.  Any time generated by these functions will show some differences in the time of the clock as it is derived from a different oscillator.

    Updates from the front panel are time by LabVIEW and the operating system. Most of the screens are updated with 60 to 80 times per second, maximum. What made the operating system, an update of the screen might be delayed by 10s of milliseconds or more.  It is certain that not all of the values at the end of the Add function will be displayed.

    Wait for him until the next ms many will wait more than 1 ms if the other code in the loop takes longer than 1 ms.  I don't know, but I think that the indicator is buffered so that any delay by the operating system to update the display should not slow down the loop. I tried to remove the flag, and it doesn't seem to make a big difference.

    I modified your VI to provide several indications of the performance. First of all, I added to the sequence of three-frame structure to allow synchronization of the loop. Second, I changed to a loop which runs a specified number of iterations. Thirdly, I hooked up the output of the timer until the next ms Multiple to a tunnel of autoindexing allowing a record of the time of each iteration appears in the table of ticks. I calculated the differences between successive instants and poster on a chart, so that you can see the performance.

    I didn't want to sound criticism of your use of English.  You write in English, much better than I could in your language!  What I was trying to make is that such general descriptions that ' Besides correctly ' without quantitative results or evidence in support of the application do not have enough information to help us help you.

    Lynn

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

  • Check the hours between 2 datetime value

    Hi all

    How can - I to select lines, where between 2 hours, doesn't bother me what date they have.

    date2 date1

    (1) 20/04/2015 08:30 20/04/2015 09:30

    (2) 21/04/2015 10:00 21/04/2015 11:00

    I have a varchar(HH24:MI) i.e. myhours = 09:15

    I have to get the first row

    SELECT count (*) of myhours between TO_CHAR (date1, 'HH24') and TO_CHAR (date2, 'HH24');

    In this case, I have to get 1 (exists), instead, if I myhours = 12:00 I get 0 (does not exist)

    Thanks in advance

    select count(*)
      from my_table
     where to_date('01-01-1900' || my_hour, 'dd-mm-yyyyhh24:mi') between to_date('01-01-1900' || TO_CHAR(date1, 'HH24:MI'), 'dd-mm-yyyyhh24:mi')
                                                                     and to_date('01-01-1900' || TO_CHAR(date2, 'HH24:MI'), 'dd-mm-yyyyhh24:mi');
    

Maybe you are looking for