Time to string to Numeric conversion

Oracle: 10g


I have a column in the table which is a time calculated and stored as follows

t_resp

4h59m38s
1d8h36m
37m29s
0 s
1 m
3: 00

Like this

How can I convert the string which consists of d-> day-> time: m-> Min minutes for comparisons and additional calculations.

Is there any direct sql statement, we can write another to write a plsql to collect for this.

Thanks in advance.

Like this

with t
as
(
select '4h59m38s' str from dual union all
select '1d8h36m' str from dual union all
select '37m29s' str from dual union all
select '0s' str from dual union all
select '1m' str from dual union all
select '3h' str from dual
)
select str,
       nvl(replace(regexp_substr(str,'[[:digit:]]*d'),'d'),0)*24*60*60 +
       nvl(replace(regexp_substr(str,'[[:digit:]]*h'),'h'),0)*60*60 +
       nvl(replace(regexp_substr(str,'[[:digit:]]*m'),'m'),0)*60 +
       nvl(replace(regexp_substr(str,'[[:digit:]]*s'),'s'),0) seconds
  from t

Tags: Database

Similar Questions

  • Problem with string to Int conversion

    Dear friends,

    Problem with string to Int conversion

    I'll have a column where most of the values is digital. Only 4 values are not numeric.

    I have replaced the non-numeric values to numeric in order to maintain the data type.

    Grade.Grade DEAL WHEN "E4" THEN "24' WHEN 'E3' THEN '23' WHEN 'E2' THEN '22' WHEN 'E1' THEN '21' Grade.Grade OTHER END"

    This is the result as inactive

    Grade

    _0_

    _1_

    _10_

    _11_

    _12_

    _13_

    _14_

    15

    _16_

    _17_

    _18_

    _19_

    _2_

    _20_

    _21_

    _22_

    _23_

    _24_

    _3_

    _4_

    _5_

    _6_

    _7_

    _8_

    _9_

    Discount
    -            -            -

    Now I want to convert this value in digital and do some math

    So I changed the formula as below

    Cast (CASE Grade.Grade WHEN "E4" THEN "24' WHEN 'E3' THEN '23' WHEN 'E2' THEN '22' WHEN 'E1' THEN '21' Grade.Grade END as an INT. ELSE")


    Now I get the following error
    View display error
    Driver Odbc _ returned an error (SQLExecDirectW). _
    Error details
    Error codes: OPR4ONWY:U9IM8TAC:OI2DL65P
    _State: HY000. Code: 10058. [NQODBC] [SQL_STATE: HY000] [nQSError: 10058] A general error occurred. [nQSError: 17001] Oracle error code: 1722, message: ORA-01722: invalid number in the OIC calling OCIStmtFetch. [nQSError: 17012] In bulk fetch failed. _ (HY000)
    SQL issued: SELECT cast (CASE Grade.Grade WHEN "E4" THEN "24' WHEN 'E3' THEN '23' WHEN 'E2' THEN '22' WHEN 'E1' THEN '21' Grade.Grade END as an int. ELSE") seen'Human Capital' 0 - Costing Manpower WHERE LENGTH (Grade.Grade CASE WHEN 'E1' THEN '20' WHEN 'E2' THEN '21' WHEN 'E3' THEN '22' WHEN "E4" THEN "23 ' ELSE Grade.Grade END) > 0 ORDER BY saw_0_

    Discount





    Could someone help me

    Concerning

    Mustafa

    Published by: Musnet on June 29, 2010 05:42

    Published by: Musnet on June 29, 2010 06:48

    Are you sure you don't have another non-digital value in your column. I want to get this filter temporarily just to check if your plaster works or not. If it works, then you can remove this filter.

  • Convert time in string

    What is the way the more efficienct to convert a time stamp control to a string of DD/MM/YYYY? I'll use its output as parameters to date in a WHERE clause of a SQL Server query.

    Date/time format string is a simple option.

  • How to connect the value of the input string to numeric values

    Hello

    I'm trying to figure out how to connect the value of unique user input string to numeric values. Basically I want the user to enter the name of a gas that I have a list for (I think I put the list of gases in a table >). Then I want to match numeric values 2 'a' and 'b', according to which gas, name of the user has set. These 'a' and 'b' values will be automatically matched with the name of the gas in a list that I put. For example, hydrogen gas has the value 3 for "a" and 4 for "b. when the user puts the ' hydrogen' name in a string constant, automatically 'a' and 'b' must be issued.» I have connect a and b to a formula

    Thanks for any help

    Hello

    It is perhaps not exactly what you are looking for, but perhaps you could use the enumerated data type and the array of clusters of points (a, b).

    Look at the VI I enclose.

  • digital conversion (in the format of the time) to string

    Hello

    I have a digital control (at the time format) in which I hours: minutes: seconds and I want to convert it to a string. The problem is that the number of hours is incremented by one, and if I insert a number of hours exceeds 24 the string is not displayed correctly.

    What should I do to make this work?

    Thank you

    You use a function that should be a numeric value that is based on the UTC clock and then convert it to a clock display based on your current time zone.  My guess is that you are in GMT + 1, which is why you see an hour added to it.

    You must use the Format function in the string for this with appropriate time for the format codes codes.    %t is relative time.  It takes number you enter and turns it into hours, minutes, and seconds, rather than trying to create a view of time for her.  This is why your code cannot ride beyond 24 hours.   (There is no 25 hours on a clock face).

  • Hexadecimal string to numeric value

    Hello

    I have a really (I think) a fundamental problem of trying to convert between a hexadecimal number to a 'digital constant' value so I can calculate certain things.

    The situation is: I'm able, a VISA series, a distance of an ultrasonic sensor reading. His current reading in an "indicator of string" ordinary put to a hexadecimal display. About 50 cm from distance with the ultrasonic at a wall sensor, I can measure "0032" as my display hex - what is optimal, 32 in hexadecimal is 50.

    However, my problem is, how do I now go to the conversion of this 0032 in hexadecimal in a usable digital/decimal numbers?

    Thanks heaps for you help.

    Nick.

    Typecaset 2 bytes of string to U16, for example as follows:

  • String to double conversion

    HI -.

    I'm trying to convert a string to scientific notation in doubles. First of all, I use a conversion of "line number" then a conversion 'duplicate '. When I probe the values my string is "+ 050.00E - 03" but the number is "50." I still have to add the part 'duplicate '. I tried to find out where and how the chain was written, but has been unable to find so it's been a bust. I think it's in the instrument drivers.

    Any suggestions?

    Thank you.

    Exactly what function "channel number"? The Fract/Exp number string works perfectly fine, as would a Scan of the chain. No need from to DBL.

  • String to number conversion problem

    I have a VI that pulls in data from a device using VISA, and I got it on another computer to work a few weeks back. I had to transfer the VI to a laptop computer to run a few tests, and now I can't make it work. I am unable to put my VI because the laptop on it's is unable to access the network companies, I will do my best to explain it all, I apologize for the inconvenience! My problem is not however with VISA, it's with an exit VISA number conversion chain.

    I have attached a painting drawing of VI to better explain it.

    I use the block series Visa football match in baud rate and all that many good things to the unit and port settings set of device management. Then, a while loop is entered. The loop will run until you press the stop"" button. The next block of visa is the writing block, he asks for a reading of the device. The next block of visa is the first block of reading, he returns playback in the form of "NA-XXX. X' where x are numbers. The next block of visa is the second reading block, this block just echoes back the command sent to the device. Playback of the first visa read block, "NA-XXX. X' is going exponential/fractional chain to digital converter.

    When you perform a run/debug to highlight run, the release of visa reports the correct value, is the value of the device reading - however the string to number converter generates a 0,000, no matter what channel number is. I am at a loss as to what may be wrong because it's the EXACT set up I had to work very well a few weeks ago!

    I'm using Labview 10 on the laptop, the old computer was labview 7. I'm guessing that this is perhaps the rub... I Redid the VI from scratch, although I have not opened the old VI in labview 10.

    Any help would be appreciated. Again, sorry I am unable to attach the VI.

    DARB wrote:

    I have attached a painting drawing of VI to better explain it.

    Would it not have been easier to just post a screenshot? You might also have used the Tool of Capture of Code. (Which reminds me that I need to install it to my previous versions of LabVIEW, as evidenced by the screenshot I took. )

    As to the question: you probably either:

    • employee analysis of chain initially and when you rewrote the VI you used the regular string conversion functions.
    • Wired an offset value in the string to the number function.

  • How to choose the value of a string are numeric together and words of letters (for example, TEST)

    Hi all

    How to choose the value of a string are letters (for example, TEST) and all numeric...

    for example
    TEST 123456
    TEST 34567
    123456 ABCD
    1234 TEST
    TESTING 12345
    TEST 1@234$
    YOUR T 123456

    I want the results of the query as below.
    TEST 123456
    TEST 34567

    And I tried to use regexp_like in this case but without success. See the code below.
    SELECT * FROM TABLE WHERE regexp_like (Description, ' [TEST] % & [[: digit:]] + $');

    How can I do this, please answer.

    Thank you

    WF

    If you want to return only the rows that contain the string 'TEST', followed by zero or more space characters, followed by one or more digits?

    How about this:

    SELECT *.

    FROM my_table

    WHERE REGEXP_LIKE(description,'^TEST\s*\d+$')

  • Converts a date into a date/time object string

    I have a JDBC call to enter data, including a date/time stamp.  For the life of me, I can't understand how to convert this string to a date/time field correct.  It is important, because I need to use validation strings to present a time more simplified users on a form.  But I like to keep the original date/time, so I can insert it again into a SQL db at the end.  I created a test process, so I can watch the progress.


    ' input string = ' 18/08/2010 16:41:23.

    Expression = dateTime-analysis-withFormat (/process_data/@datestring,"yyyy/MM/dd hh', 'FR', 'US', 'WIN',"CDT")

    Result = 18 August 2010 22:41:23 this

    So I try to put this value into a date field and I get the error:
    : Invalid ISO8601 DateTime:August 18, 2010 21:41:23 GMT:java.text.ParseException: date of: "August 18, 2010 22:41:23 this."


    I tried like 100 different variations to associate with an object date and time with the same result.  I can use the functions of analysis-dateTime or analysis-dateTime-withFormat throughout the day, but I can't get this string value in a proper date field.  Any ideas?  Please help as I'm about to pull out my hair... ... who won't be pretty.

    (Note: I know that my time zone came through OK but I am not concerned about it right now)

    To resolve this problem, I use ExecuteScript activity with the code:

    import java.util.Date;
    import impossible;

    String dateString = patExecContext.getProcessDataStringValue ("/ process_data/@input");

    SimpleDateFormat formatter = new SimpleDateFormat ("yyyy-MM-DD hh: mm :"); ")
    Date date = (Date) formatter.parse (dateString);

    patExecContext.setProcessDataValue ("/ process_data/result", date);

    where

    entry - process line with the dates of the string variable '2010-01-01 23:59:59 '.

    Date - date process variable

  • The decimal string to number Conversion, cutting necessary zeros

    I'm new to the forum, but have been using labview for awhile. Finally found something that really puzzled me, hope I can find someone who is smarter than me! It may be something obvious too, but here goes. The attached vi is the cause of the error. I have a serial number I need to convert a decimal string into a number, I use later the number of "math" so he need as a number. The system always receives a serial number of 6 characters (ie. 123456), but today the system has received a serial number with two leading figures of the scale (ie. 003456) zeros. This compensation of all the bells of alarm stream (sent 4 digits), but the error found that started the 'intelligence' at the beginning of the monitoring program. I would like to know if there is a way to force the zeros in the decimal number in string to not shave off the coast of the 6-digit value above.

    File is located in LabVIEW 2014

    Ideas or comments, thank you!

    The problem is not the string functions.  This is the display format for your digital indicator.  Change the properties on that.

  • By using the Date/Time Format String function Vi

    I wanted to display the time in milliseconds to Labview and I got it to work. I want to display AM or PM after the milliseconds so it looks like this

    31/05/11 4:45:39.849 PM

    I use %p as you can see from the picture, but it does not work. AM or PM does not appear.

    What I am doing wrong?

    Thanks in advance.

    Replace your hour % I. Hour is 24 hours which has no designation A.m. or p.M. You must use the time of 12 hours.

  • string to double conversion table

    Hello

    I try to convert the string in the array in DBL, but I can't find the function

    Someone can help me. my program is attached

    Thank you

    Use "fact/Exp string to number. http://zone.NI.com/reference/en-XX/help/371361H-01/Glang/fract_exp_string_to_number/

  • BUG: Date/Time Format string with %D in the format string crashes LabVIEW

    Do %D in the format string 'Format string DateTime' blocks LabVIEW 2009 SP1, as shown in this code snippet.  Should I use instead of %D %d but an incorrect format string should not crash LabVIEW.

    Fixed in 2010.

  • string to numeric

    Hello.

    I try to make a communication RS232 with Labview with freescale Flexis microcontroller, the communication is made, but data becomes how a data string and try to connect with a thermometer but send a message error, weel the problem is that I can't convert string into digital data data.

    Please help me.

    Sorry with my English, but I speak only Spanish

    There is a decimal string to the function of numbers that you might try.

    If the string is simply a decimal figures representing the temperature, which should take care of it.

    Hope that helps

    Hummer1

Maybe you are looking for

  • HP Pavilion dv6-2160em laptop missing drivers

    Hello! I tried to find the drivers for DV6-2160em, but in the software/drivers for laptop on the home page, a missing link. I used this link: http://h10025.www1.hp.com/ewfrf/wc/product?product=4126571&lc=en&cc=us&dlc=en&lang=en&cc=us and if I use ano

  • Windows/Microsoft Update crashes, takes all the CPU can't be fixed by all the recommendations I found

    Windows XP, SP3, it worked fine. Suddenly Windows/Microsoft Update crashes and uses all the CPU while trying to assess what needs to be updated. The only way to stop him is to kill the process. A ran Fixit from Microsoft (support.microsoft.com/kb9491

  • Adding external speakers to T232HL

    Can I add external speakers with my T232HL monitor.  Internal speakers in the monitor, but I would like an extra volume when listening to music.

  • SBH 52 headphones with microphone

    I used this camera and everythink works fine except one thing. When I connect my headset with microphone (romaric Piston 2.0), and then uses SBH52 build-in microphone instead of what is in my helmet. I tried Googling this problem, but without success

  • Change the type of user account is not updated

    I changed my account type standard user principal and account invited to administrative yesterday. Now, I want to change it back but is not allow me to change my primary administrative standard. I can click on it, but it is not updated. What should I