Vchar2 in time - PL Sql

I have 2 columns time in my data in vchar2 format. I tried several suggestions from this forum on how to convert (to_date and to_char) and can't make it work. My ultimate goal is to remove these 2 times to see the difference in minutes.

BLOCKED_DATE RMBL_TIME_START RMBL_TIME_STOP
01/05/2012 07:00 17:00
01/05/2012 07:00 19:00
05-02-2012 07:30 19:30
05-02-2012 07:30 17:30
03/05/2012 07:00 17:00
03/05/2012 07:00 19:00
04/05/2012 07:30 17:00
04/05/2012 07:30-19:00

Source: room_blocked_vw

I get an error invalid number when you use to_char or simply by subtracting the 2 fields. I get error of non-numeric values with to_date. I tried to concatenate the date and time with these functions as well.

Thanks in advance for your help.

Jason

A bit similar to Etbins solution:

select 1440*
    to_number(to_date(lpad(RMBL_TIME_STOP,5,'0'),'hh24:mi')
                - to_date(lpad(RMBL_TIME_START,5,'0'),'hh24:mi')
       ) from yourtab;

Tags: Database

Similar Questions

  • Expiration date and time in SQL server 2008 Enterprise Edition

    Please tell me the exact expiration Date and time in SQL Server 2008 Enterprise, and 2008R2 edition?

    Please tell me the exact expiration Date and time in SQL Server 2008 Enterprise, and 2008R2 edition?

    Hello

    Please post this question in the SQL Server forum.

    Category of the SQL Server:

    http://social.technet.Microsoft.com/forums/en-us/category/SQLServer

    Concerning

  • Need help to record execution time of SQL in the database

    Hello
    I have an interesting thing that I am tiring to do. I want to record how much time (wall clock) it took the database to execute a select statement against a particular view lets call it CUST_ORDERS_V.

    I want to check which ran, what the select statement (SQL text) and how long it took and perhaps a few other auxiliary things if possible.

    Research in most of my needs me to right audit Oracle and the SYS. AUD $ table. After you set up auditing with:
    audit_trail=db,extended
    
    and
    
    audit select on ME.CUST_ORDERS_V by access;
    I get every piece of information that I need, except for the time of execution. Wow that would be awesome if Oracle who recorded! So I thought that if I could. I was considering a trigger on SYS. AUD$ (I know bad thoughts) which would look at some reviews of $ V and get the runtime and write this in other tables custom with a link back to SYS. AUD$.

    Maybe this is the complete wrong way to do it. I was wondering if anyone had any ideas on that.

    I'm running on 11.2.0.3 EA. I'm on EA if I use Fine grain audit if necessary. However I DO NOT have the Tuning or Pack diagnosis.

    Sky13 wrote:
    It's a call center and people on phones have learned that they can blame the database for their lack of productivity. Knowing the TSMITH selected in the 210 view times in his shift and the DB responded within the "Acceptable" range 99.5% of the time would be invaluable.

    If you're running at three levels (and this seems very likely) then your intermediate level probably has a record feature which can be enabled via a change of a line in a configuration file so that it will write a log record in a flat file for each call to the database with information such as : (source, time, start sql statement, return time). It is probably a better place to find a solution to your problem.

    Concerning
    Jonathan Lewis

  • How to access a certain date in the date and time field SQL Server

    I have a field named job_date in a table in my database of the 8 SQL Server.

    The data type is datetime.

    Thus, the values for the fields as the 2013-03-11 15:55:52.000 look.

    How to query this field to include only the values of a certain date?

    For example

    < cfquery name = "get_job_name" datasource = 'abc' >

    SELECT FROM job_info job_date WHERE Job_name = March 12, 2013"

    < / cfquery >

    When I query the field now I get NO RECORDS.

    This is because as the fields like this 15:55:52.000 2013-03-11. instead of this March 12, 2013"

    How to access a certain date in the date and time field SQL Server when its formatting as this 15:55:52.000 2013-03-11. ?

    where job_date > = TheDateYouWant

    and job_date<>

    In addition, the format is irrelevent.  The only issue of date formats time is when you want to display.

  • How to make the sum of the time through SQL?

    Dear friends

    I have a sh_detail table and there are three fields hours1, hours2 hours3. all fields are of type varchar2.

    data are like

    hours1 hours2 total hours3

    02:45 00:18 01:25

    00:38 01:45 00:00

    02:15 02:00 00:15

    1. I want to add on three fields in the total column

    2 and want to make the sum of all areas as select sum (hours1) of sh_detail.

    Please help I will be grateful.

    Kind regards.

    As others have said, use the NUMBER to store times, or the type of data correct INTERVAL, even if the latter cannot be aggregated (using the SUM).

    In the meantime, this will give you the output desired in a few minutes (it is trivial to convert it back in format hh: mm if you wish):

    SQL> with sample_data (id, hours1, hours2, hours3) as (
      2    select 1, '02:45', '00:18', '01:25' from dual union all
      3    select 2, '00:38', '01:45', '00:00' from dual union all
      4    select 3, '02:15', '02:00', '00:15' from dual
      5  )
      6  select id
      7       , sum(h1) h1
      8       , sum(h2) h2
      9       , sum(h3) h3
     10       , sum(h1+h2+h3) as total
     11  from (
     12  select id
     13       , to_number(substr(hours1, 1, 2))*60 + to_number(substr(hours1, 4, 2)) as h1
     14       , to_number(substr(hours2, 1, 2))*60 + to_number(substr(hours2, 4, 2)) as h2
     15       , to_number(substr(hours3, 1, 2))*60 + to_number(substr(hours3, 4, 2)) as h3
     16  from sample_data
     17  )
     18  group by rollup(id) ;
    
            ID         H1         H2         H3      TOTAL
    ---------- ---------- ---------- ---------- ----------
             1        165         18         85        268
             2         38        105          0        143
             3        135        120         15        270
                      338        243        100        681
    
  • Elapsed time in sql developer

    Hello

    For the script below how do we get the execution time for package below in sql developer
    set SERVEROUTPUT on
    set timing on
    VARIABLE OND REFCURSOR;
    execute PKG_ISR_CAF_CDNG_ORG_STRUCT.PROC_GETORGNODES_NEW_3959(10005543,'MANAGE', 10006746, :OND);
    PRINT OND;

    Hello

    This seems to be one of those cases where sheet SQL and SQL Developer * more behavior differ. Use of the "timing" on value in SQL * Plus will provide time for both execution of the procedure of a package, but also a call refcursor impression. A SQL Developer worksheet won't display any elapsed time for a SQL * more the print command, but if you replace your run with the following:

    VARIABLE OND REFCURSOR;
    BEGIN
    PKG_ISR_CAF_CDNG_ORG_STRUCT.PROC_GETORGNODES_NEW_3959(10005543,'MANAGE', 10006746, :OND);
    END;
    /
    PRINT OND;
    

    an elapsed time is then displayed for anonymous block.

    You want to maybe visit the SQL Developer Exchange and add a feature request for this feature if a request does not already exist.

    Kind regards
    Gary
    SQL development team

    Published by: Gary Graham on April 24, 2012 15:19
    Or go to additional lengths as JB is done in the following post:
    Re: Execute a Package/procedure - takes time to answer (3.1)

  • The sense of time in sql

    Hi all

    A simple matter of time spent in v$ sql.

    I know that this means that a total duration when a query runs.

    I think that

    time elapsed time = cpu + user + application_wait_time o wait times
    + concurrency_wait_time + cluster_wait_time + plsql_exec_time + java_exec_time

    of course, the passage of time could not be exactly the same with a sum of above things, because its value is the cumulative value.

    but I have a few weird data. its value is 130% of the amount. I have no idea whence the other 30%.

    its value is too big to ignore.

    does anyone have an idea?

    (this is a kernel environment)

    Thanks in advance...

    Hello
    If you draw the session (10046) an application, following will be the result in the file path for each SQL statement

    SELECT "COSTCODE","INSERTDATETIME","LOTID","SOURCELOTID","STAGE","SUPPLIERID"
    FROM
     "ACTL_PARTINFO_CUST" "A" WHERE "SUPPLIERID"='RD1' AND "INSERTDATETIME"=
      TO_DATE('2010-08-18 07:05:00', 'yyyy-mm-dd hh24:mi:ss') AND "STAGE"=:1 AND
      "LOTID" LIKE 'C%' AND "COSTCODE"='A' AND "SOURCELOTID" LIKE 'F%'
    
    call     count       cpu    elapsed       disk      query    current        rows
    ------- ------  -------- ---------- ---------- ---------- ----------  ----------
    Parse        1      0.00       0.00          0          0          0           0
    Execute 300372      3.27      69.85          0          0          0           0
    Fetch   300371   1916.42    6551.42          0  100023544          0           0
    ------- ------  -------- ---------- ---------- ---------- ----------  ----------
    total   600744   1919.69    6621.27          0  100023544          0           0
    
    Misses in library cache during parse: 0
    Optimizer mode: ALL_ROWS
    Parsing user id: 61  (DWDB_REPORTING)
    
    Elapsed times include waiting on following events:
      Event waited on                             Times   Max. Wait  Total Waited
      ----------------------------------------   Waited  ----------  ------------
      SQL*Net message to client                  300371        0.02          0.64
      SQL*Net message from client                300371        5.33       4860.35
      latch: cache buffers chains                  7199        0.38         49.62
      latch free                                     99        0.04          0.72
      latch: enqueue hash chains                      5        0.03          0.07
    

    Here you can see the total elapsed time next to the database including waiting events.

    Salman

  • Filteration time in SQL

    I want to get result form table that store the date and time in the card_date column. When I run this query, it will display data from the entire date but I need within a specified date period.

    DATE1: 04/06/2009 23:23
    DATE2: 04/06/2009-23:30

    SELECT i.employeecode, i.employeename, i.fathername, i.shiftcode,
    accName (dated_department (i.employeecode,: date1)) department.
    accName (dated_designation (i.employeecode,: date1)) designation.
    card_date, map
    FROM cardprinting c, identification I have
    WHERE the TO_DATE(C.Card_Date,'dd-mm-rrrr HH24:MI') BETWEEN TO_DATE (: Date1, "dd-mm-rrrr HH24'")
    AND TO_DATE (: Date2, "dd-mm-rrrr HH24 '")
    AND (i.employeecode = c.empcode)

    Hi you enter date a seconds also so the format mask to give which allows to test

    SQL> create table test_table(col1 varchar2(20),col_date1 date);
    
    Table created.
    
    SQL> insert into test_table values ('abc',to_date('6-APR-2009 11:25:00 PM','DD-MON-RRRR HH:MI:SS PM'
    ));
    
    1 row created.
    
    SQL>
    SQL> insert into test_table values ('xyz',to_date('6-APR-2009 11:45:00 PM','DD-MON-RRRR HH:MI:SS PM'
    ));
    
    1 row created.
    
    SQL>
    SQL> insert into test_table values ('pqr',to_date('6-APR-2009 11:26:00 PM','DD-MON-RRRR HH:MI:SS PM'
    ));
    
    1 row created.
    
    SQL>
    SQL> insert into test_table values ('uvw',to_date('6-APR-2009 11:20:00 PM','DD-MON-RRRR HH:MI:SS PM'
    ));
    
    1 row created.
    
    SQL>
    SQL> insert into test_table values ('mno',to_date('7-APR-2009 11:30:10 PM','DD-MON-RRRR HH:MI:SS PM'
    ));
    
    1 row created.
    
    SQL> select * from test_table;               ----select all rows from the table.
    
    COL1                 COL_DATE1
    -------------------- -----------------------
    abc                  06-APR-2009 11:25:00 PM
    xyz                  06-APR-2009 11:45:00 PM
    pqr                  06-APR-2009 11:26:00 PM
    uvw                  06-APR-2009 11:20:00 PM
    mno                  07-APR-2009 11:30:10 PM
    
    ----------------selecting rows with search criteria.
    
    SQL> select * from test_table where col_date1 between to_date('6-APR-2009 11:23:00 PM','dd-mon-rrrr
    hh:mi:ss pm') and
      2  to_date('6-APR-2009 11:30:00 PM','dd-mon-rrrr hh:mi:ss pm');
    
    col1                      col1_date1
    --------------              --------------------------------
    abc                       4/6/2009 11:25:00 PM
    pqr                       4/6/2009 11:26:00 PM
    

    If you want to change the output set the date format in SQL * MORE use

    SQL> alter session set nls_date_format='DD-MON-YYYY HH:MI:SS PM';
    
  • Group by time in sql query

    Hello

    Version: 9i R1

    TI

    ----------

    RESTCODE VARCHAR2 (2)

    DATE OF BILLDATE

    LIGNESDE NOT NULL NUMBER (2)

    ITEMCODE NOT NULL NUMBER (5)

    BILLNO NUMBER (8)

    ITEMPRICE NOT NULL NUMBER (7.2)

    QTYSOLD NOT NULL NUMBER (8.2)

    STAX NOT NULL NUMBER (5.2)

    SMODE NOT NULL CHAR (1)

    PAX NOT NULL NUMBER (5)

    CREATE TABLE TI

    (RESTCODE, VARCHAR2 (2),)

    DATE OF BILLDATE,

    LIGNESDE NUMBER (2.0) NULL NOT ACTIVATE.

    ITEMCODE NUMBER (5.0) NOT NULL ACTIVATE.

    BILLNO NUMBER (8.0).

    ACTIVATE THE NUMBER ITEMPRICE (7.2) NOT NULL,

    QTYSOLD NUMBER (8.2) NOT NULL ACTIVATE.

    ACTIVATE THE NUMBER STAX (5.2) NOT NULL,

    ACTIVATE THE SMODE CHAR (1) NOT NULL,

    SELECT NUMBER (5.0) PAX NON-NULL

    ) PCTFREE, PCTUSED, INITRANS 40 10 1 MAXTRANS 255 LOGGING

    STORAGE (INITIAL 65536 THEN 1048576 MINEXTENTS 1 MAXEXTENTS 2147483645 PCTINCREASE 0)

    TABLESPACE FREELISTS USERS 1 FREELIST GROUPS 1 DEFAULT USER_TABLES)

    BEGIN

    INSERT INTO TI VALUES (TO_DATE '10' (10-SEP-2013 04:15:15 "," DD-MON-YYYY HH24:MI:SS'), 1,1,1,100.00,1,1, THE OF ', 10);

    INSERT INTO TI VALUES (TO_DATE '10' (10-SEP-2013 04:25:15 "," DD-MON-YYYY HH24:MI:SS'), 1,1,1,100.00,1,1, THE OF ', 10);

    INSERT INTO TI VALUES (TO_DATE '10' (10-SEP-2013 04:45:15 ',' DD-MON-YYYY HH24:MI:SS'), 1,1,1,50.00,1,1, THE OF ', 10);

    INSERT INTO TI VALUES (TO_DATE '10' (10-SEP-2013 05:25:15 "," DD-MON-YYYY HH24:MI:SS'), 1,1,1,10.00,1,1, THE OF ', 10);

    INSERT INTO TI VALUES (TO_DATE '10' (10-SEP-2013 05:45:15 ',' DD-MON-YYYY HH24:MI:SS'), 1,1,1,100.00,1,1, THE OF ', 10);

    INSERT INTO TI VALUES (TO_DATE '10' (10-SEP-2013 06:15:15 "," DD-MON-YYYY HH24:MI:SS'), 1,1,1,400.00,1,1, THE OF ', 10);

    INSERT INTO TI VALUES (TO_DATE '10' (10-SEP-2013 06:25:15 "," DD-MON-YYYY HH24:MI:SS'), 1,1,1,100.00,1,1, THE OF ', 10);

    INSERT INTO TI VALUES (TO_DATE '10' (10-SEP-2013 06:45:15 ',' DD-MON-YYYY HH24:MI:SS'), 1,1,1,200.00,1,1, THE OF ', 10);

    END;

    Like this, I want the output.  No matter who can provide you with, query for that?

    RESULT

    *******

    Time sales

    *****    ******

    4 to 5 250.00

    5 to 6 110.00

    6 to 7 700.00

    Hello

    Here's another way:

    SELECT TO_CHAR (TRUNC (billdate, "HH"), "FmHH24 my - DD - YYYY")

    ||  To_char (TRUNC (billdate, "HH") + (1/24) ", '" to "fmHH24" "") IN time

    , SUM (itemprice * qtysold) AS total_sales

    OF ti

    GROUP BY trunc (BILLDATE, "HH")

    ORDER BY trunc (BILLDATE, "HH")

    ;

    If the time is 05:00 precisely, the amount is included in the Group of 5 to 6 "and not in the Group of 4 to 5".

  • Date format time: PL/SQL

    create or replace

    TEST procedure as

    -remove all instances of more 30 days

    number of l_days: = 7;

    date of l_cur_datetime;

    Start

    run immediately "alter session set current_schema = dev_soainfra';"

    l_cur_datetime: = sysdate - l_days;

    How then can I convert the format YYYY-MM-DD hh: mm: l_cur_datetime

    Hello

    TO_CHAR (l_cur_datetime, 'YYYY-MM-DD hh24:mi:ss') - 24 hour format

    TO_CHAR (l_cur_datetime,'YYYY-MM-DD hh AM: mi: ss')

    What do you mean by MM:MM:MM

  • First time: Developer SQL connect to DB

    Need help with entries TNS not showing TNSNames entries.

    I do not have a TNSNames file?

    There is no need to attack people.

    The solution was obvious: he added manually the connections.

  • How can I find an SQL executed and completed on time?

    Hello

    Could you please help me I want to learn started and finish time for SQLs?
    If it is possible?

    DB version: 9.2.0.8

    Thanks and greetings

    Published by: OracleADay on May 12, 2011 16:23

    What term you ask little more describe

    If in terms of query executed last time, this link will be helpful

    http://forums.Oracle.com/forums/thread.jspa?threadID=927452

  • How to messure time CPU elapsed for a sql on ten times

    Hello

    I want to messure CPU time of SQL to Timesten,

    Could you help me messuring CPU elapsed time for sqls,

    How to messure sql time CPU elapsed TT DB, is there no way in sql trace that what we are doing for Oracle Tkprof.

    Thank you
    -AK

    Published by: AK08 on June 1st, 2010 22:43

    Another thought...

    If you have access to the o/s level or the compiler profiling tools, you could build a version profiled the application and observe the proportion of time spent in the ODBC calls. Maybe it's a different approach.

    Chris

  • How to know the execution time of query in sql plus

    Hello

    I want to know the duration of execution of query in sql more accompanied by statistics

    I say time is set on;
    Set autotrace on;
    Select * view where usr_id = "abcd";


    If the result is 300 lines it scrolls up until all the rows are retrieved and finally gives me the run time in 40 seconds, or 1 minute... (it is after all records scrolls)

    but when I run it in Toad he gives 350 milli seconds...

    I want to see the execution time in sql how to proceed

    client and database server 11g is g 10

    concerning
    REDA

    In sqlplus you can do set autotrace traces to suppress the display of the selected lines.

    John

  • How to set up a database of Eve 'apply in real time '.

    Hi all

    11 GR 2,

    Rhel6

    How to set up real-time apply such as the transactions are updated in near real-time to the wait, even without switching to log files?

    For example, we have 1 GB size redo logs and assuming that it will take 1 day to fill these newspapers. This means that our expectation will be entitled to 1 day delay of data?

    This means we lost 1 day of a disaster at the primary data value? because the redo log was not able to move the log files?

    Thank you very much

    JC

    Hello

    Hope this helps

    Real time apply ---> all committed changes should have been applied in standby mode

    How to:

    standby mode

    SQL > alter database recover managed standby undo;

    SQL > change managed database recovery ensures assistance to disconnect log current;        --> You should have SRL and this command works up to 11g, 12 c apply by default start with real time

    At the primary level: check the recovery mode:

    SELECT DEST_ID, RECOVERY_MODE FROM V$ ARCHIVE_DEST_STATUS WHERE DEST_ID = 2;

    Read only apply with--> is called as--> ACTIVE DATA GUARD redo apply when the database is open read-only


    standby mode

    SQL > alter database recover managed standby undo;

    SQL > alter database open read-only.

    SQL > change managed database recovery ensures assistance to disconnect log current;        --> You should have SRL and this command works up to 11g, 12 c apply by default start with real time

    SQL > select name, open_mode, controlfile_type, db_unique_name from v$ database;

    Thank you

Maybe you are looking for

  • McBook will not icloud backup

    My macbook pro and the devices won't save to icloud. I'm not 43 GB available, please advise. I tried almost everything... Thank you.

  • Intermittent hard drive looking for the light. White screen.

    My Pavillion Office refused to start today with light orange hard drive "will not blink" in the quick flicker even way while trying to start.  Its flashing for a longer period with a consistent pace of about one and a half seconds per blink. I remove

  • Satellite Pro P300 - install the graphics driver

    Hi all This is my last resort before I throw this laptop through the window - and it is a gift for someone for Christmas. I recently bought a Satellite Pro P300 - model PSPC1E-005008EN, 2 GB RAM, 17 "display and Intel GMA X 3100 video card. As a very

  • Sedentary refund?

    So yesterday, I was issued a refund to a point that I bought it. I checked my account Transactions and he said that it is "established" I wondered what that meant because I have yet to see the money in my bank account. Thank you

  • ASUS PC probe II. Initially, Windows will block upward.

    equipped with windows vista ultimate.  last update of windows (this week) has caused this problem.ASUS PC probe II.  Initially, Windows will block upward.  No information given as to how to tell vista to leave him alone, I want it to run at startup u