How to calculate the time difference

Hi friends,

I want to calculate and the sum of the time difference.

I have two fields in a table. Inside and OUTSIDE. for example.

OUT IN DIFFERENT

01:46 15:30?

01:47 15:45?

02:50 17:30?

I want less above figure and the result will appear in different column.

Help, please

Kind regards

Hello

Assuming that the two columns are the VARCHAR2 data type and "represent" the hours and minutes:

WITH sample_data AS (SELECT ' 01:46 ' in_col, 15:30 ' out_col FROM DUAL)

UNION ALL

SELECT ' 01:47 ' 15:45 ' OF THE DOUBLE

UNION ALL

SELECT ' 02:50 ', 17:30 ' OF THE DOUBLE

)

SELECT in_col,

out_col,

TO_CHAR (TO_DATE ((TO_DATE(out_col, 'HH24:MI')-TO_DATE(in_col, 'HH24:MI')) * 86400, «SSSSS»), "HH24") differ))

OF sample_data;

SQL > WITH sample_data AS (SELECT ' 01:46 ' in_col, 15:30 ' out_col FROM DUAL)

2. ANY TRADE UNION

3. SELECT ' 01:47 ' 15:45 ' OF THE DOUBLE

4 UNION ALL

5. SELECT ' 02:50 ', 17:30 ' OF THE DOUBLE

6                      )

7. SELECT in_col,

out_col 8,.

9 to_char (TO_DATE ((TO_DATE(out_col, 'HH24:MI')-TO_DATE(in_col, 'HH24:MI')) * 86400, «SSSSS»), "HH24") differ))

10 FROM sample_data;

IN_COL OUT_COL DIFFER

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

01:46 15:30 13:44

01:47 15:45 13:58

02:50 17:30 14:40

SQL >

Tags: Database

Similar Questions

  • How to calculate the time difference in the two date columns time.

    Hi Obiee Experts,

    I came back new requirement on obiee 10g.


    I have two date columns in my table time, data as below.

    StartDate: 18/03/2012-04:40:51

    Closing date: 18/03/2012-04:50:55

    I want to the output as below (Jet lag).

    output
    04:40:51 (less)-04:50:55 = 00:10:04

    I hope you understand my requirement in OBIEE.

    Note: I want to show above the output values in another State for OBIEE10g column.

    Please share me your valuable contributions. Urgent appeals.

    Thank you
    Satya

    Hi Satya,

    Here's another solution. You can try the formula below as it is:

    Cast (floor (TIMESTAMPDIFF (sql_tsi_second, '-SNP_SESSION '.))) SESS_BEG, '-SNP_SESSION '. SESS_END) / 3600) as char). ':' ||
    Cast (floor (mod (TIMESTAMPDIFF (sql_tsi_second, '-SNP_SESSION '.)))) SESS_BEG, '-SNP_SESSION '. ((SESS_END), 3600) / 60) as char). ':' ||
    Cast (mod (TIMESTAMPDIFF (sql_tsi_second, '-SNP_SESSION '.))) SESS_BEG, '-SNP_SESSION '. SESS_END), 60) as char)

    I would like to know if that's what you're looking for.

    Thank you

  • calculate the time difference.

    Hello

    How to calculate the time difference by using javascript.

    Example 15.05 and18.35 difference is 2 h 30 min

    BTW: it isn't ~ 2h30min is 3h30min

    Maybe something like this works:

    // result is 3.300000000000002 ~ 3h 30min
    (parseFloat((18.35 - 15.05) / 3600) * 3600)
    
  • How to calculate the time to SELECT

    I want to know how to calculate the time taken by the SELECT query.

    For example: I run a select statement in TOAD (oracle version 9i) who takes 40 seconds to run, but in the output window, it displays few records. It says "list 1 of 500 records, more records exist". This table has total 20 million records.

    Now my question is: have you my SELECT query took 40 seconds? or it took 40 seconds to SELECT 500 records.

    If it took 40 seconds to SELECT 500 records then how to calculate the total amount?

    Any help would be much appreciated.

    To avoid the exit which is probably not really need you can make

    begin
      for c in (select * from xy /*your query */)
      loop
        null;
      end loop;
    end;
    /
    

    This gives an estimate of the time to recover all the lines.

  • Is there an easy way to calculate the time difference?

    I am trying to find a way to calculate the time difference between

    here at a certain time

    var settime:Number = 02:35

    and

    now would be getDate();

    I tried something rediculus, but it does not work when I entered a date less than 24 hours, is there a class out there who can just this kind of things

    or y at - it something on the internet that could tell me the difference between different time

    Thank you

    My attempt

    var date: Date = new Date();

    Set timer to what would I like to call the function
    var lastcallH:Number = 22;
    var lastcallM:Number = 50;
    var lastcallS:Number = 0;

    Set up of the 24-hour clock
    var tHour:Number = 24;
    var tMinute:Number = 60;
    var tSecond:Number = 60;

    Get the current time
    var cHour:Number = date.getHours ();
    var cMinutes:Number = date.getMinutes ();
    var cSeconds:Number = date.getSeconds ();

    Set the first variable
    var fH:Number;
    var fM:Number;
    var fS: Number;

    A second set of Variable
    var sH: number;
    var sM:Number;
    var sS:Number;

    Final conversion for the Timer
    var finalMil:Number;

    Time variables that will need to be converted

    If (lastcallH < Thur)
    {
    fH = chorus - Thur;
    fM = cMinutes - tMinute;
    fS = cSeconds - tSecond.
    finalMil = (sH * 60) + (sM * 60) + (sM * 60);
    }
    ElseIf (cMinutes > 0 | cSeconds > 0) {}
    ++ Choir;
    ++ cMinutes;
    fH = chorus - Thur;
    fM = cMinutes - tMinute;
    fS = cSeconds - tSecond.
    }
    else {}
    fH = chorus - Thur;
    fM = cMinutes - tMinute;
    fS = cSeconds - tSecond.
    }

    sH = fH + lastcallH;
    sM = fM + lastcallM;
    sS = fS + lastcallM;

    If (< 0 sH: sM < 0 | sS < 0)
    {
    sH = sH * (-1);
    sM = sM * (-1);
    sS = sS * (-1);
    }
    finalMil = (sH * 60) + (sM * 60) + (sM * 60);

    Allows you to implement a timer
    var yahooTime:Timer = new Timer (finalMil, repeat);
    var repeat: Number = 1;

    yahooTime.start ();

    yahooTime.addEventListener (TimerEvent.TIMER, displayCall);

    function displayCall(event:TimerEvent):void
    {
    trace ("well let's success");
    }

    your first trace() statement is almost certainly not what you want.

    dtDate2 is 08/08/2009

    and it's probably not what you want.  Flash months are zero-based.  That is to say, January corresponding to month 0 and December is the month 11.

  • How to calculate the time

    I want to calculate the time. I want to subtract ' 01:00:00 ' AM currently, but I am getting error.

    SQL > /.
    Select to_char('01:00:00','HH24:MI:SS')-to_char(sysdate,'HH24:MI:SS') double
    *
    ERROR on line 1:
    ORA-01722: invalid number

    can someone help me

    Thank you

    Not sure what you mean. If you want to subtract an hour from a date, keep in date arithmetic spirit uses day as a unit. To subtract an hour from a date, you need to subtract 1/24:

    SQL> alter session set nls_date_format = 'MM/DD/YYYY HH24:MI:SS'
      2  /
    
    Session altered.
    
    SQL> select sysdate,sysdate - 1/24 from dual
      2  /
    
    SYSDATE             SYSDATE-1/24
    ------------------- -------------------
    08/09/2009 09:55:28 08/09/2009 08:55:28
    
    SQL> 
    

    SY.

  • calculate the time difference between several lines

    Hello

    I have a table as below:

    create table select TEST_CASETBL (ID, CASE_NUM, CASE_STATUS, CASE_SUB_STATUS, LAST_UPD_DTTM)

    112, 123-456', 'open', 'Work', TO_DATE (11 March 2015 13:00 ',' dd/mm/yyyy hh24:mi:ss') of the DUAL union all select

    113, 123-456', 'Open', 'pending on the admin', TO_DATE (10 January 2015 15:00 ',' dd/mm/yyyy hh24:mi:ss') of the DUAL union all select

    114, 123-456', 'Open', 'client expectation', TO_DATE (10 July 2015 09:00 ',' hh24:mi:ss' of dd/mm/yyyy) of the DUAL union all select them

    315, 123-456', 'open', 'Work', TO_DATE (September 15, 2015 10:00 ',' dd/mm/yyyy hh24:mi:ss') of the DUAL union all select

    219, 123-456', 'Open', 'pending on the admin', TO_DATE (January 9, 2015 08:00 ',' dd/mm/yyyy hh24:mi:ss') of the DUAL union all select

    651, 123-456', 'open', 'Work', TO_DATE (August 20, 2015 10:00 ',' dd/mm/yyyy hh24:mi:ss') from DUAL;

    I would like to calculate the duration total (days ideally) to CASE_SUB_STATUS, so have a set of lines:

    CASE_NUM of work waiting on admin waiting on customer

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

    123-456 70days 6 hours

    Here is the explanation of the pattern:

    ex: for everyday business computing (timestamp timestamp of ID:651 - ID:219) +(timestamp of ID:315-timestamp of ID:114) + (ID:112 stamp - current_time) = 11 days + 21 days 22hrs 23hrs 36 days 9 hours

    still waiting on admin

    (ID:219 timestamp - timestamp of ID:315) + (ID:113 timestamp - timestamp of ID:112)

    still waiting on the client

    (ID:114 timestamp - timestamp of ID:113)

    I would appreciate any idea how to solve this, ideally as an SQL

    Thank you

    Should he not?...

    with test_casetbl (id, case_num, case_status, case_sub_status, last_upd_dttm) as)

    Select 112, 123-456', 'Open', 'Work', TO_DATE (11 March 2015 13:00 ',' dd/mm/yyyy hh24:mi:ss') of all the DOUBLE union

    Select 113, 123-456', 'Open', 'pending on the admin', TO_DATE (10 January 2015 15:00 ',' dd/mm/yyyy hh24:mi:ss') of all the DOUBLE union

    Select 114, 123-456', 'Open', 'client expectation', TO_DATE (10 July 2015 09:00 ',' dd/mm/yyyy hh24:mi:ss') of all the DOUBLE union

    Select 315, 123-456', 'Open', 'Work', TO_DATE (September 15, 2015 10:00 ',' dd/mm/yyyy hh24:mi:ss') of all the DOUBLE union

    Select 219, 123-456', 'Open', 'pending on the admin', TO_DATE (January 9, 2015 08:00 ',' dd/mm/yyyy hh24:mi:ss') of all the DOUBLE union

    Select 651, 123-456', 'Open', 'Work', TO_DATE (August 20, 2015 10:00 ',' the hh24: mi: ss' dd/mm/yyyy) double

    ),

    t like)

    Select case_num,

    case_sub_status,

    (last_upd_dttm, 1, sysdate) ahead of diff last_upd_dttm (partition by order of last_upd_dttm case_num).

    of test_casetbl

    )

    Select case_num,

    trunc (a) | "day (s). TO_CHAR (date ' 1-1-1' + a, "fmhh24" 'mi' minute (s) "ss" second (s) hour (s)"") "work."

    trunc (b) | "day (s). TO_CHAR (day 1-1-1' + b, "fmhh24" 'mi' minute (s) "ss" second (s) hour (s)"") 'Waiting on admin',

    trunc (c) | "day (s). TO_CHAR (day 1-1-1' + c, "fmhh24" 'mi' minute (s) "ss" second (s) hour (s)"") "waiting on customer."

    t

    pivot)

    Sum (diff)

    for case_sub_status in)

    'Work' is.

    B "waiting on admin',

    C "customer expectation."

    )

    )

    CASE_NUM Working Waiting on admin Waiting on customer
    123-456 63 day (s) 22 hour (s) (s) 50 minute 49 second (s) 19 day (s) on 20 (s) hour 0 minute 0 second (s) 27 day (s) on 4 hour (s) 0 minute 0 second (s)
  • How to calculate the time interval

    Dear Gururs,

    I have table of details of the calls as below

    Call_Detail DESC;
    Name of Type Null
    --------- ---------- --------------
    Appeal of VARCHAR2 (20)
    VARCHAR2 (20) called
    Time DATE

    in other words table contains each call on a day like this

    The call | Called | Time
    ========================================
    A | B | January 1, 2011 00:02:00
    A | B | January 1, 2011 00:08:00
    A | B | January 1, 2011 00:18:00
    A | B | January 1, 2011 00:22:00
    A | B | January 1, 2011 00:30:00
    A | B | January 1, 2011 00:31:00

    I want output like below

    The call | Called | Time | Time Difference (sec)
    ==============================================================
    A | B | January 1, 2011 00:02:00 | 360
    A | B | January 1, 2011 00:08:00 | 600
    A | B | January 1, 2011 00:18:00 | 240
    A | B | January 1, 2011 00:22:00 | 480
    A | B | January 1, 2011 00:30:00 | 60
    A | B | January 1, 2011 00:31:00 | 0

    Could someone help to above.

    Concerning
    Sanjeev

    Hello

    Use the analytical fucntion of LEAD to get a value on the next line.
    For example:

    SELECT       calling
    ,       called
    ,       NVL ( ( LEAD (time) OVER ( PARTITION BY calling
                                                ,               called
                             ORDER BY     time
                           )
                 - time
                 ) * 24 * 60 * 60
               , 0
               )     AS time_difference_sec
    FROM      call_detail
    ORDER BY  calling
    ,            called
    ,       time
    ;
    

    If you would care to post CREATE TABLE and INSERT statements for your sample data, and then I could test this.

    Published by: Frank Kulash, January 11, 2011 10:18

  • How to set the time difference between each data when using keithley 2400 scanning

    Hello friends,

    I use scanning Keithley vi the extent of SCANNING and acquire vi. I want to measure the voltage for each step and a pause between each two data, so I need a delay between each I step.

    I'm a starter to use Labview, thank you very much for your answers.

    Perry

    As Dennis says, if you use the built-in scan function, you will need to consult the manual. See Section 10-16 (this is page 10 of article 16, only paragraphs not but 10, 16) for the manual Keithley 2400.

    The Keithley 24xx series has a speed of measurement in units called PLC (Power Line Cycles). The default speed is 1PLC, which means a measure is taken with each cycle of line 1 power supply or 1/60th of a second (16.67ms). 24XX can range from 0.01 PLC (all 0.16ms) 10 PLC (all 166.6ms). The faster you measure, the less accuracy you get.

    To programmatically set this value, the command is

    ENSe:CURRent:NPLCycles

    ENSe:VOLTage:NPLCycles

    Depending on what you are sensing and where is the number of controllers from 0.01 to 10.

    Another factor that will determine the time between data points is the cycle SDM. These are more complicated, look at your Keithley manual for more information. Look at article 6 and article 11 for more information.

    Note:

    PLC times are based on a cycle of 60 Hz US.

  • How to calculate the difference in response times

    Hello
    I need to calculate the time difference of BI answers and I don't have access to the repository. I have the data in the following format

    2005-10-12 19:24:19 12/10/2005 19:32:04
    2005-10-12 19:50:47 2005-10-12 20:52:36
    2005-10-12 19:54:23 04/11/2005 22:47:32
    2005-10-12 21:05:51 12/10/2005 21:08:58
    2005-10-12 21:07:42 12/10/2005 21:14:47
    2005-10-12 21:09:02 12/10/2005 21:10:57
    I need to get the hours of elapased between these two columns. Please help me

    Thank you

    TimeStampDiff (SQL_TSI_HOUR, table.column1, table.column2)

  • How to calculate the execution time of a SCTL in FPGA VI?

    Hello

    Can someone guide me that how to calculate the execution time of a SCTL for an iteration in the FPGA VI?

    Thank you and best regards,

    Rashid

    Hello r,.

    A SCTL will always run in a beat the clock it has been linked to.  So, if you use a 40 MHz clock, this loop will run in 25 ns.  If the code cannot complete in that, or if it requires two graduations of the watch to do the calculation, your code does not compile, then you have the guarantee that this will always be how long it takes this piece of code to run.

  • How to calculate the execution time of a loop?

    Hello

    Can someone guide me that how to calculate the execution time of a loop to iterate?

    Thank you and best regards,

    Rashid

    I hope I have your question! See attached screenshot

  • How to calculate the loading time of BDB startup

    Hi all

    I understand that Berkeley DB at startup it will read a few pages from the disk in the memory cache, but I don't know the exact number of pages that will load. I think that BDB will load default pages as much as possible in the cache until the cache is full. Is this good?

    And how to calculate the cost of time on the loading process? Can it be verified using db_stat?

    Thank you very much

    Hello.

    There is a discussion on how proceed (preload the cache) in this thread:
    Re: a question about read file or cache

    Ben Schmeckpeper

  • How do the time difference between two dates?

    Hi all

    I use this query to get the time difference between two dates.

    Select to_timestamp ('2012-10-03 12:00 ',' YYYY-MM-DD hh)-to_timestamp ('2012-10-03 11:00 ',' YYYY-MM-DD hh) as double diff;

    but do not get the correct result.

    Thank you

    Left KEY... Left Padding of tanks.

  • To build the waveform.vi function how to calculate the value of dt

    Dear all

    Please guide me How to calculate the value of dt according to waveform.vi of construction

    My sampling rate is 25000 and I take 200000 samples.

    Kind regards

    Muhammad Irfan

    It's all simple arithmetic. The inverse of the sampling frequency power of samples is then the dt or the time between samples the number of samples is not relevant.

Maybe you are looking for

  • substitute 6 s iPhone questions

    Hey guys. IM writing because I'm a little desperate right to know. I bought a new unit of the iphone 6 s about three months ago and it was really ok. good battery life (as a new phone should) and no hardware or software problem. But after these three

  • HP ENVY 4500 all-in-one: ENVY 4500 advance Options

    How to add or remove in the menu the paper size set in the Advanced Options screen?

  • Want to downgrade from Windows 7 to XP using the upgrade disc

    I installed windows 7 on my laptop. Many problems. Tried to re - install Windows xp with a upgrade version, but will not recognize windows 7 upgrade to xp. How to re-install xp with a upgrade disk. * original title - replaced with win7 winxp. have xp

  • How can I manually turn on my screensaver in Windows 7

    In Windows XP, it was quite simple create a shortcut on your desktop to manually turn on your screen saver. I don't see how to do the same thing in Windows 7

  • Why my display driver keep on crashing?

    Whenever I try to play a game in full screen, the screen flashes black and there are black stripes. Finally, it stops, and the game ends. Sometimes, the computer restarts, and occasionally, the message "display driver has stopped working and has full