difference between two timestamps

Hi gurus,

I have a procedure which has 2 input parameters of type timestamp. I need to find the difference between these two stamps and be converted to a timestamp and return. Help, please

Diifernce between two timestamps is interval. You can not convert the difference between two timestamp timestamp and it makes no sense. What you expect:

25/06/2014 11:25:37.524000 - 13:07:22.987654 20/06/2014

SY.

Tags: Database

Similar Questions

  • How to store the difference between two timestamps as a number?

    Hello
    I need to find the difference between 2 variables of timestamp and the result will be stored as a number in minutes?
    as
    declare
    timestamp (7) of the fir_timestamp: = 1 January 2012 13:30 ';
    timestamp (7) of the sec_timestamp: = 1 January 2012 14:00 ';
    c number;
    Start
    c:=((sec_timestamp-fir_timestamp)/(24*60));
    dbms_output.put_line (c);
    end;

    962813 wrote:
    declare

    -fir_timestamp timestamp (7): ='01 - jan - 2012 13:30 ';
    timestamp (7) of the sec_timestamp: = 1 January 2012 14:00 ';  Incorrect type declaration

    fir_timestamp timestamp: = 1st January 12 01.30.00.000000 PM';
    sec_timestamp timestamp: = 1st January 12 02.00.00.000000 PM';
    c number;
    Start
    c: = ABS ((extrait (HEURE de sec_timestamp) - extract (fir_timestamp TIME)) * 60) +.
    ABS ((extrait (MINUTE de sec_timestamp) - extract (fir_timestamp MINUTE)));
    dbms_output.put_line (' interval Min Total:-' | c);
    end;
    /
    declare
    *
    ERROR on line 1:
    ORA-01830: date format picture ends before converting all of the input string
    ORA-06512: at line 6

    Follow what Paul has done...

    In fact, you do not need timestamp, date data type is enough

    SQL> declare
      2     fir_timestamp date :=
      3        to_date('01-jan-2012 13:30:00','dd-mon-yyyy hh24:mi:ss');
      4     sec_timestamp date :=
      5        to_date('01-jan-2012 14:00:00','dd-mon-yyyy hh24:mi:ss');
      6     c number;
      7  begin
      8     c:= round((sec_timestamp-fir_timestamp)*24*60);
      9     dbms_output.put_line(c);
     10  end;
     11  /
    30
    
    PL/SQL procedure successfully completed.
    

    If you want to place on timestamp

    SQL> declare
      2     fir_timestamp timestamp :=
      3        to_timestamp('01-jan-2012 13:30:00','dd-mon-yyyy hh24:mi:ss');
      4     sec_timestamp timestamp :=
      5        to_timestamp('01-jan-2012 14:00:00','dd-mon-yyyy hh24:mi:ss');
      6     c number;
      7  begin
      8     c:= round((
      9     to_date(to_char(sec_timestamp,'ddmmyyyyhh24miss'),
     10             'ddmmyyyyhh24miss')-
     11          to_date(to_char(fir_timestamp,'ddmmyyyyhh24miss'),
     12             'ddmmyyyyhh24miss')
     13           )*24*60);
     14     dbms_output.put_line(c);
     15  end;
     16  /
    30
    
  • Type of data resulting from the difference between two timestamps

    Hi, I have a simple question.
    I have two TIMESTAMP A and B variables. Now I want to subtract one B - A. What type of data as a result of this subtraction?
    Would Shouln t TIMESTAMP again?

    Consider this example:
    DECLARE
       vdat_Begin        TIMESTAMP;
       vdat_End          TIMESTAMP;
       vdat_Difference   TIMESTAMP;
    BEGIN
       vdat_Difference := vdat_End - vdat_Begin;   -- this doesn't work
       vdat_Difference := TO_TIMESTAMP(vdat_End - vdat_Begin);   -- this works
    END;
    /
    
    PLS-00382: expression is of wrong type
    Thanks for help.

    xxsawer wrote:
    Hi, I have a simple question.
    I have two TIMESTAMP A and B variables. Now I want to subtract one B - A. What type of data as a result of this subtraction?
    Would Shouln t TIMESTAMP again?

    Consider this example:

    DECLARE
    vdat_Begin        TIMESTAMP;
    vdat_End          TIMESTAMP;
    vdat_Difference   TIMESTAMP;
    BEGIN
    vdat_Difference := vdat_End - vdat_Begin;   -- this doesn't work
    vdat_Difference := TO_TIMESTAMP(vdat_End - vdat_Begin);   -- this works
    END;
    /
    
    PLS-00382: expression is of wrong type
    

    Thanks for help.

    No, as stated, there will be an interval.

  • calculate the difference between two timestamps

    Hello
    I'm new in PL/SQL and have the following problem. In our application, there are events that insert records into a table with a parameter "processing_date" of type DATE (when they will be processed). For a new type of events, I have to plan the 'processing_date' at 18:00 on the day of insertion, if the event has happened until 18:00 and sysdate if event occurs after 18:00.
    In a pseudo-code that will be
    IF to_char(SYSDATE,'HH24:MI:SS') > 17:59 min 59 s ' THEN - the event took place after 18:00
    processind_date: = sysdate;
    Else - the event has happened until 18:00
    processing_date: = current_timestamp + ('timestamp at 18:00 ' - current_timestamp); -> processing_date: = today at 18:00
    END IF;

    I'll appreciate any help.

    Thank you.

    dariusgeo wrote:
    processing_date: = current_timestamp + ('timestamp at 18:00 ' - current_timestamp); -> processing_date: = today at 18:00

    For 18:00 of the current date, you can do:

     processing_date := TRUNC(SYSDATE)+18/24;
    

    TRUNC will be truncates the current date ' 00:00:00 '.
    Add 18/24 means add 18 hours (1 day / 24 * 18).

    Kind regards.
    Al

    Published by: Alberto Faenza 22 may 2013 22:07

  • How to find the difference between two dates in the presentation layer

    Hi gurus,

    Hello to everyone. Today, I came with the new requirement.


    I need to know the difference between a date and the current date in the formula column application presentation layer.by.



    Thank you and best regards,
    Prates

    Hi Navin,

    TIMESTAMPDIFF function first determines the timestamp component that corresponds to the specified interval setting. For example, SQL_TSI_DAY corresponds to the day component and SQL_TSI_MONTH corresponds to the component "month".

    If you want to display the difference between two dates in days using SQL_TSI_DAY, unlike butterflies SQL_TSI_MONTH and so on...

    hope you understand...

    Award points and to close the debate, if your question is answered.

    See you soon,.
    Aravind

  • Difference between two data aquistion

    Hello

    I got a data aquistion system that is supposed to keep data acquisition selection until the difference between two points a lot. For example, I get voltage (mv) as 2.31, 2.32, 2.34. 2.33 2.32, 2.33 2.32. the data up to a point, say 0.1V higher or lower than the first. Thewhole procss stop. Thank you for your suggestions.

    Try this... (Labview 8.2)

  • difference between two dates in the year/month/day in Obiee

    Hi gurus,

    I know this question have been asked and answered several times but I have a requirement that is a little different, then the previous ones.

    I want to calculate the difference between two dates in OBIEE10g in year/month/day format similar to the below SQL output

    SQL > select end_date, start_date,

    trunc (months_between (end_date, start_date) / 12) years.

    months of mod (trunc (months_between (end_date, start_date)), 12).

    End_date - add_months (start_date, trunc (months_between (end_date, start_date))) days

    t

    Thanks in advance

    SK

    Search for this

    "TIMESTAMPDIFF IN THE FORM OF MTHS # YEARS."

    or else

    To get the current mandate of employees since the date of hiring in the form of # years # mths or # year (s) # month (s)

    Concat (concat (cast (TIMESTAMPDIFF (SQL_TSI_Month, "Employee attributes". (((' ' Hiring last Date employee ", CURRENT_DATE) / 12 as char),"Year (s)"), concat (cast (MOD (TIMESTAMPDIFF (SQL_TSI_Month,"Employee attributes". (((((' ' Hiring last Date employee ", CURRENT_DATE), 12) as char), 'Month (s)'))

    Concat (concat (CAST (TIMESTAMPDIFF (SQL_TSI_YEAR, "Employee attributes". (((' ' Hiring last Date employee ", CURRENT_DATE) as CHAR),"Year (s)"), concat (cast (MOD (TIMESTAMPDIFF (SQL_TSI_Month,"Employee attributes". (((((' ' Hiring last Date employee ", CURRENT_DATE), 12) as char), 'Mth (s)'))

  • Exact differences between two images

    I need to be able to tell the difference between two images of a pastel artwork.


    The first image is of the piece, to be hung on a wall or placed on a table.


    The second is a photo of the piece after it has been moved, shaken or vibrated during which time particles were moved.


    I tried superimposing the two images and see the difference between the layers.  The images never seem to perfectly align along the lines of reference drawn in ink on the piece, and I do not understand the presentation of grayscale of the layer mode of difference.  I would like to know if anyone has any photographic photoshopic, or insightful ideas on how to capture this specific detail of change.  Another big challenge is now the images themselves to the exact distance and exposure to the room at the before and after photos, especially if they were taken in two different places on different dates.

    Best I can think of is to load into Photoshop layers >, select the two layers and go Edit > auto alignment of layers.  Then to the blending mode of the layer from the top to the difference.

    You can test so that you know what to expect by opening an image and copy the layer of BG and setting the blending mode of the layer copied the difference.  It will show as a pure black.  Now make tiny changes to the upper layer.

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

  • Difference between two times

    I am building a working method in LiveCycle, and I want to track how long the procedure takes. To do this, I have two time fields, and then a third time field to find the difference between two time fields. Looking at other posts to discussion, I could find a Javascript code that was part of what I wanted, but I can't get the third time field to display in the format I want. I tried to change the habits of the fields and that did not work. Could someone offer some advice on how to change the format or help me with the code?  I couldn't figure to attach the actual file, but I have attached a picture of the PDF file and the Javascript code I used.  If you look at the TimeIn (hh: mm) and time (hh: mm) areas (on the photo, I have attached), you will notice that the TotalTime comes out like HMM, and I want that it out as hh: mm.

    Adobe Time Difference Example.jpg

    Javascript Time Difference Code.jpg

    Any help would be greatly appreciated!

    Thank you

    this.rawValue = (totalHrs > 9? String (totalHrs): '0' + String (totalHrs)) + ':' + (totalMins > 9? String (totalMins): '0' + String (totalMins));

  • Find the difference between two date and time

    Hi friends,

    I wanted to find the difference between two date and time, but my qury is slightest error "invalid number."

    select sql_step_num,proc_name,run_seqno,start_date,end_date,(to_char(start_date,'HH24-MI-SS') - to_char(end_date,'HH24-MI-SS') ) as ed  
    from eval.EVAL_RUNTIME_DETAILS
    where trunc(start_date) = trunc(sysdate) 
    order by sql_step_num;

    You try to get the feel between two char strings.
    And more difference between two dates gives a NUMBER of days.
    Try this:

    select sql_step_num,proc_name,run_seqno,start_date,end_date,numtodsinterval(end_date-start_date,'DAY') as ed
    from eval.EVAL_RUNTIME_DETAILS
    where trunc(start_date) = trunc(sysdate)
    order by sql_step_num;
    
  • Find the difference between two numbers (DBL)

    Hi all

    Is there a function in labview other than the subtraction function that can find the difference between the two numbers given?

    Thank you

    Davidson


  • Difference between two numbers of laptop models

    Can someone tell me if there is a difference between these models of computers two laptops? As far as I can tell they are the same.
    M7-j120dx and M7-J010D. Thank you.

    Hello

    To the second machine:

    http://support.HP.com/us-en/document/c03770540

    You can check yourself, BUT I found at least 2 things that tell me that the first one is the best: it has screen FULL HD and better card WiFi (b/g/n a/c).

    Kind regards.

  • Difference between two dates

    Hello

    I have two columns both of them date data types.

    I would like to know the difference between these two dates.

    SELECTION INTERVAL ' + 2342 23:23:23 ' DAY (4) TO THE SECOND - INTERVAL ' + 102 13:13:13 ' DAY (4) SECOND FROM DUAL;

    But, I get this:

    '+ 2240 10:10:10.000000'

    I'd like to see the result in a year-month and jour-deuxieme groups. I can't do anything with + 2240 days...

    Thanks in advance!

    Hello Adme12

    You can use it.

    SET LINESIZE 110 PAGESIZE 20

    COLUMN today FORMAT A20

    COLUMN TOMORROW FORMAT A20

    COLUMN YEAR_MONTHS FORMAT A15

    COLUMN DAY_SEC FORMAT A30

    SET ECHO ON

    SELECT TO_CHAR (today, ' JJ.) MR. HH24:MI:SS' YYYY) LIKE TODAY

    , TO_CHAR (tomorrow, ' JJ.) MR. HH24:MI:SS' YYYY) TOMORROW

    NUMTOYMINTERVAL (MONTHS_BETWEEN (TOMORROW, TODAY), 'MONTHS') AS YEAR_MONTHS

    , NUMTODSINTERVAL (TOMORROW - ADD_MONTHS (TODAY, TRUNC (MONTHS_BETWEEN (TOMORROW, TODAY))), 'DAY') AS DAY_SEC

    Of

    (SELECT SYSDATE + INTERVAL ' + 102 13:13:13 ' DAY (4) ON THE SECOND THAT TODAY ' HUI)

    , SYSDATE + INTERVAL ' + 2342 23:23:23 ' DAY (4) ON THE SECOND TOMORROW

    OF THE DOUBLE

    )

    ;

    TODAY TOMORROW YEAR_MONTHS DAY_SEC

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

    23.04.2014 04:49 10.06.2020 14:59:10 + 000000006-02 + 000000018 10:10:10.000000000

    Of course, it is not so good that you have so many 0, but you can convert the result to a char (TO_CHAR) and you can enter.

    I hope this helps you!

    Kind regards

    David

  • Number of hours of the weekend between two timestamps

    I'm trying to take two timestamps and the total number of hours weekend between them.  For example:

    Between October 23, 13 08.28.00.000000 AM and 28 October 13 04.48.25.424940 PM, there are two weekend days.  I want the query to return the 48 hours.

    Between October 24, 13 04.48.25.424940 PM and 01.00.00.000000 October 27, 13 h ago weekend day plus 13 hours Sunday, I would that this return to 37 hours.

    Database version:

    Oracle Database 11 g Enterprise Edition Release 11.2.0.3.0 - 64 bit Production

    PL/SQL Release 11.2.0.3.0 - Production

    "CORE 11.2.0.3.0 Production."

    AMT for Linux: Version 11.2.0.3.0 - Production

    NLSRTL Version 11.2.0.3.0 - Production

    Create / Insert statements:

    CREATE TABLE 'TDIFF.

    (NUMBER OF 'ID',

    "TS1' TIMESTAMP (6).

    ('TS2' TIMESTAMP (6));

    Insert into TDIFF (ID, TS1 and TS2) values (1, to_timestamp (17 October 13 02.09.01.818304000 PM ',' DD-MON-RR HH.MI.)) PSM AM FF'), to_timestamp (30 October 13 09.16.00.000000000 PM ',' DD-MON-RR HH.MI.) PSM AM FF '));

    Insert into TDIFF (ID, TS1 and TS2) values (2, to_timestamp (21 October 13 01.23.58.258494000 PM ',' DD-MON-RR HH.MI.)) PSM AM FF'), to_timestamp (24 October 13 10.00.00.000000000 AM ',' DD-MON-RR HH.MI.) PSM AM FF '));

    Insert into TDIFF (ID, TS1 and TS2) values (3, to_timestamp (07.33.10.874721000 AM October 23, 13 ',' DD-MON-RR HH.MI.)) PSM AM FF'), to_timestamp (24 October 13 10.00.00.000000000 AM ',' DD-MON-RR HH.MI.) PSM AM FF '));

    Insert into TDIFF (ID, TS1 and TS2) values (4, to_timestamp (09.12.41.928313000 AM October 23, 13 ',' DD-MON-RR HH.MI.)) PSM AM FF'), to_timestamp (25 October 13 02.30.00.000000000 PM ',' DD-MON-RR HH.MI.) PSM AM FF '));

    Insert into TDIFF (ID, TS1 and TS2) values (5, to_timestamp (10.12.22.790736000 AM October 23, 13 ',' DD-MON-RR HH.MI.)) PSM AM FF'), to_timestamp (24 October 13 06.40.00.000000000 PM ',' DD-MON-RR HH.MI.) PSM AM FF '));

    Insert into TDIFF (ID, TS1 and TS2) values (6, to_timestamp (10.33.20.879307000 AM October 23, 13 ',' DD-MON-RR HH.MI.)) PSM AM FF'), to_timestamp (25 October 13 04.24.00.000000000 PM ',' DD-MON-RR HH.MI.) PSM AM FF '));

    Insert into TDIFF (ID, TS1 and TS2) values (7, to_timestamp (11.01.23.467642000 AM October 23, 13 ',' DD-MON-RR HH.MI.)) PSM AM FF'), to_timestamp (24 October 13 07.00.00.000000000 AM ',' DD-MON-RR HH.MI.) PSM AM FF '));

    Insert into TDIFF (ID, TS1 and TS2) values (8, to_timestamp (23 October 13 04.45.08.237177000 PM ',' DD-MON-RR HH.MI.)) PSM AM FF'), to_timestamp (07.00.00.000000000 AM October 25, 13 ',' DD-MON-RR HH.MI.) PSM AM FF '));

    Insert into TDIFF (ID, TS1 and TS2) values (9, to_timestamp (23 October 13 04.48.25.424940000 PM ',' DD-MON-RR HH.MI.)) PSM AM FF'), to_timestamp (28 October 13 08.28.00.000000000 AM ',' DD-MON-RR HH.MI.) PSM AM FF '));

    This is what I have so far, but his return the number of incorrect hours:

    SELECT TS1,TS2,
      (SELECT COUNT(*)
       FROM DUAL
       WHERE TO_CHAR(TS2 + LEVEL - interval '1' hour, 'DY') IN ('SAT', 'SUN') 
    CONNECT BY LEVEL <= 24*extract(DAY FROM TS2-TS1)+extract(hour FROM TS2-TS1) + 1 ) D1_WEEKEND_HOURS
    FROM TDIFF
    

    Any ideas are appreciated.

    -Steve

    Here is another way, assuming a definition of the weekend as strictly between midnight Friday and midnight Sunday:

    The interval of D1 to D2 can be considered be allowed between the D1 and the next 00 Monday more time between Monday preceding the D2 and D2 as well as the weeks between the two Monday to 00:00.

    select  id, ts1, ts2,
    ( least(7 + (trunc(CAST(ts1 as DATE), 'IW') - CAST(ts1 as DATE)), 2) /* ts1 to Monday */
    + greatest( (CAST(ts2 as DATE) - trunc(CAST(ts2 as DATE), 'IW')) -5, 0) /* Monday to ts2 */
    + 2/7 * (trunc(CAST(ts2 as DATE), 'IW') - trunc(CAST(ts1 as DATE), 'IW') -7 ) /* Weeks between Mondays */
    ) * 24
    from TDIFF
    

Maybe you are looking for