[Oracle 8i] How to convert a string (timestamp) in a date?

I find it difficult to know how to convert a string to a date time stamp (or possibly several).

The timestamp is 20 positions, character (NOT NULL, CHAR (20))
in the format: YYYYMMDDHHMMSSUUUUUU
where Y = year, M = month, D = day, M = Minutes, S = seconds and U = microseconds

The reason why I want to convert it is so that I can compare a timestamp to each other (that is, I want to be able to find the MIN (timestamp), MAX (timestamp) and make comparisons of inequality).

Is this possible?

Thanks in advance for the help on this!

Hello

As Damorgan said, if all you want to do is find which is the earlier or later, then you can just compare the strings: they are in a format where it works.

If you need to do other things, such as compare to today date or see the difference between two of your lines of days, you will need to convert it to date. (He has no reason to convert them to numbers).

A new TIMESTAMP data type, which manages the fractions of a second, was introduced in Oracle 9.
Since you use Oracle 8 (depending on your subject line), or it must be
(1) ignores the microseconds, or
(2) use a separate column for microseconds.

Whatever it is, use TO_DATE to convert the first 14 characters in DATE:

TO_DATE ( SUBSTR (txt, 1, 14)
        , 'YYYYMMDDHH24MISS'
        )

where txt is your column of type CHAR.
To convert microseconds to a number (between 0 and 999999):

TO_NUMBER (SUBSTR (txt, 15))

Tags: Database

Similar Questions

  • How to convert a string and use a rope as a property?

    I have an array in the following format:

    {ownsCar: 'true', ownsBike: 'true', ownsHouse: 'true'}

    {ownsCar: ownsBike 'false',: 'true', ownsHouse: 'true'}

    {ownsCar: 'true', ownsBike: ownsHouse 'false',: 'true'}

    etc ............

    And I need to test against each element, for example

    If...

    myDataGrid ["myItem"] .ownsCar is object (myCheckbox) .label

    ... then

    If...

    myDataGrid ["myItem"] .ownsBike is object (myCheckbox) .label

    ... then

    If...

    myDataGrid ["myItem"] .ownsHouse is object (myCheckbox) .label

    ... then

    But I have to build my application where the property (for example 'ownsCar', 'ownsBike', 'ownsHouse') is a variable such as:

    If...

    myDataGrid ["myItem"] .myProperty is object (myCheckbox) .label

    ... then

    I would like to browse my table, by counting the number of items and then use each element as a property.

    How to convert the string (for example, "ownsCar") in a property "myProperty"?

    Thanks in advance

    Chris

    OK, if I got this right what you need to do is introspection.

    The easiest way to do this would be:

    for ( var propertyName:String in myObject ) {
         // Do what you need with this here:
         myObject[ propertyName ];
    }
    
  • How to convert a string to a number?

    How to convert a numeric string to a number of TestStand?

    Use Val().

    Example Val (Locals.myString)

  • How to convert the string with numbers in U8 with ascii

    Hello

    I have a string with only numbers 0. 9 paper.

    Now, I want to convert to table-U8.

    He works here, but now the problem: How can I change each character to its ascii value?

    Example:

    entry: 123 (string)

    output: x 31, x 32, x 33 (U8-array)

    Thanks for the help

    It's very easy

    String to Byte Array Function
    Have the Palette: string/array/path Conversion functions

    Converts a string to an array of unsigned bytes. Each byte in the array has the ASCII value of the character corresponding to the string.

  • How to convert the string in milliseconds

    Hello

    Please suggest how I can convert a string (October 9, 1989) in milliseconds...

    If it has a certain format, you can use HttpDateParser, otherwise create a calendar object, set the relevant values and get the time to it.

  • How to convert the string to a full decimal point and left shift

    Hey guys I tried to convert gps string to an integer, like this

    A string that is 2467.8976 and I need to convert it to a similar integer as point of this 2467.8979 so that I can shift the decimal point to the left (24.678979) which i coudnt do it with the chain. It's just been my 2 weeks with the labview so be gentle. Thank you

    Hi Awais07,

    Once you have created an indicator that signals the output of parsing the string, right-click on this indicator > display... Format > increase the value of the digit 9

    Kind regards

    Lennard.C

  • How do to convert the string (with the Hex data) in number?

    Hello

    I use TestStand 3.5 to automate a few test cases associated with boot loader.

    The requirement is that I need to read the value in some places for specific address. The values of these addresses are stored in a hexadecimal format.

    We have a step customized in TestStand through which we can read these values by address, but she returns as the type "String".

    For example, the value to 0 x 0000008 is 000001 B 2, and he returned in Locals.Value_Read as "000001 B 2" in the string.

    Is it possible, I can convert the string "000001 B 2" to a number?

    I tried to use the function-> val (locals. Value_Read), but it is return 0 as TestStand figures that the input string is not representing the valid number.

    Please help me with this.

    Thank you and best regards,

    Niraj.

    Try: Val ("0 x" + Locals.Value_Read)

  • How to convert a string to byte array

    Hello

    I want to convert a string with a hexadecimal number in the array of bytes, this string includes a cutting-edge information, but I don't want to add this tip to arry bytes.

    detailed information please see the photo. I hope someone can give me some instructions, thank you very much.

    The accepted solution of Giedrius.S is not correct, based on the image shown in the first post. That the solution will not eliminate the spaces before the tip, and the string to byte array to convert individual characters '0', '8', 'space', '9', etc. for them to byte values. The right solution, based on the image below:

  • Portal Oracle Gold: how to convert insert them in the update

    In my db goal there is no delete replicated.

    But sometimes, the same key is removed and inserted in the future.

    In this case, how to convert insert them in the update?

    Kind regards

    William

    I have

    If I use this option:

    RESOLVECONFLICT (INSERTROWEXISTS, (BY DEFAULT, OVERWRITE))

    ???

  • How to convert a string literal function function valid

    Hello

    I have a situation where I need to get the built-in (sysdate/sysdate-1/sysdate-2) as variables. As the variable is taken as a string, it is considered as a string, not a function. Is it possible to convert the string literal in valid function.

    Here is an example for better understanding. I used v_var to store the 'sysdate-1 "in the form of string literal. Try to change the value.


    */*-------------------------------------------------------------------------------------*/*
    declare

    v_var varchar2 (20): = ' sysdate-1';
    date of v_var2;

    Start

    Select v_var in the double v_var2;

    dbms_output.put_line ('v_var2: ' | v_var2);

    end;

    */*-------------------------------------------------------------------------------------*/*


    Thanks in advance

    Or

    SQL>  var str varchar2(20)
    SQL>  exec :str := 'sysdate - 1'
    PL/SQL procedure successfully completed.
    
    SQL>  select trim(dbms_xmlgen.getxmltype('select ' || :str || ' s from dual').extract('//text()')) str from dual
    /
    STR
    ------------------------
    15.07.09
    1 row selected.
    
  • How to convert a string of data to a table 1 d

    Dear all,

    I wonder if someone can help me.

    In the attached Elf, I have my program (in labview 8.6) who read the updates and the data of temperature for the time.

    I want to use temperature update in a calculation.  How can I get the new temperature I think it's in a format string and convert it into table 1 d?

    I tried, but the number I got the temperature wasn't the same temperature, which is shonw in the section of the program data.

    Could someone help me please?

    Kind regards

    You do not read the temperature, you read a binary file. You seem to be assuming that the string format, but do you really know? Nobody here can say since you do not have the file, if it is you need to use one of the functions of conversion of the string. And please, get rid of the local data variable. You're already usin shift registers. Do the same with the data from the file.

  • How to convert the string with numbers in the table of Boolean 2D

    Hello

    I have input a string with comma separated numbers 1,192 (starting at 1).

    This string must be converted to a table 2D-boolean. Each number that appears should be true, not true rest.

    The 2D table consists of 4 times of 0.47 Boolean values.

    1.48--> [0.47] numbers [0]
    49.96--> [0.47] numbers [1]
    Numbers 97.144--> [0.47] [2]
    145.192--> [0.47] numbers [3]

    If a '1, 49, 97 145' input string put all [0] [0.3] true.

    How can it be easy/fast resolved?

    Thanks for help

    Break the string of numbers in a table of numbers.  (Spreasheet String to Array).

    In a loop For, index with each issue of this table.  Use in the range and Coerce to see if it is in the range of numbers.  (You can put this in a loop For as auto good indexing through the ranges).  If it's in the range, then use subset replace table to activate the corresponding item in a real.  If this is not the case, do nothing.  Maintain the table of Boolean in a shift register.

    Repeat this step for each number in your table.

    (What is a class assignment?)

  • How to convert the string stored in a column in lines

    Hi gurus,
    BANNER
    ----------------------------------------------------------------
    Oracle Database 10g Release 10.2.0.3.0 - 64bit Production
    PL/SQL Release 10.2.0.3.0 - Production
    CORE    10.2.0.3.0      Production
    TNS for Linux: Version 10.2.0.3.0 - Production
    NLSRTL Version 10.2.0.3.0 - Production
    I have following string

    Sports / Sports cards / Basketball / Baseball

    I want to convert as follows

    Sport
    Sports cards
    Basketball
    Baseball

    Any help would be very appropriate.

    Thanks in advance

    On 10g:

    with t as
    (select 'Sports / Sports Cards / Basketball / Baseball' as col from dual)
     SELECT
            case pivot
              when 1 then
            regexp_substr(t.col, '[^/]+', 1, 1)
              when 2 then
            regexp_substr(t.col, '[^/]+', 1, 2)
              when 3 then
            regexp_substr(t.col, '[^/]+', 1, 3)
              when 4 then
            regexp_substr(t.col, '[^/]+', 1, 4)
            end case,
      pivot
      from t,  (SELECT rownum pivot from dual CONNECT BY LEVEL <=4)
    
  • How to convert varchar in timestamp

    "in the comic book, I have an indtalledDate of column with a varchar data type - and value is as ' Thu Dec 20 07:33:20 PST 2012." Now, I need to convert this format of timestamp-> 20 December 12 07.47.49.463000000 AM. How can I do?

    can someone pls help?

    Check this box:

    SELECT CAST (
              TO_TIMESTAMP_TZ ('Thu Dec 20 07:33:20 PST 2012',
                               'Dy Mon DD HH:MI:SS TZR YYYY') AS TIMESTAMP)
      FROM DUAL
    

    See you soon,.
    Manik.

  • How to convert a string to a data type double

    I'm eager to take a string representation of a number and convert it to an INT64 data type to perform a function.  What can I use for this?

    Do a right click on the blockdiagram... go to programming--> string--> sting / numberconversion--> fract/expstringtonumber

Maybe you are looking for