conversion of data types

Hello

How to convert date data type number data type:

Using to_char and to_number

Thank you

Published by: josh1612 on November 17, 2008 12:37 AM

What are your needs. What is your output of input and expected.

Without that no one can give you the right solution. And why you want to convert first date in number?

Somehow here is an example.

SQL> create table t(dt date)
  2  /

Table created.

SQL> insert into t values(sysdate)
  2  /

1 row created.

SQL> select * from t
  2  /

DT
---------
17-NOV-08

SQL> select to_char(dt,'ddmmyyyy') from t
  2  /

TO_CHAR(
--------
17112008

SQL> select to_number(to_char(dt,'ddmmyyyy')) from t
  2  /

TO_NUMBER(TO_CHAR(DT,'DDMMYYYY'))
---------------------------------
                         17112008

Tags: Database

Similar Questions

  • Conversion from data type "float".

    In a wireless data logger I collect analog data with a 8-bit microcontroller and sending it as a UDP datagram. The data received in the LV application looks like this:

    \r\n020.43\s002.14\s000.00\s000.02\s ("------" "" display codes)

    0D0A 3032 302F 3433 2030 3032 2E31 3420 3030 3030 2030 3030 2E30 3220 (display Hex) 302F

    020.43 002.14 000.02 000.00 (normal display)

    I want to undress and show values 20.43, 2.14,0.0 and 0.02 in my application of LV.  Try with "Scan of the String" and "Decimal number to the string" but without much success. Maybe I can 'building' my data of the hexagon?

    Any idea is welcome. Thank you.

    Channel scan works very well for me.

  • Control data type conversion

    Topology Manager only allows me the conversion to data type of technology to another. SQL Server has a data type BIT. Default is to convert to a CHAR in Oracle. However, it coverts TANK (1) and the interface fails because the data contains "True" or "False" as values. This forces me to change manually (5) tank & then run again. How can I adjust the settings so that the BIT converts char (5) instead of char (1)?

    Thank you
    Dinesh.

    Hi dieng

    Go to the topology, under Oracle and create a new data type, name char5 for example.

    In the text box NAME and CODE OPPOSITE the word "TANK" in the CODE, let's CHAR5 text box

    in the text box: CREATE the TABLE SYNTAX and SYNTAX of DATA WRITEBLE of writing type: char (5)

    In the tab "Convet to", you can associate the SQL BIT for this new data type.

    This help you?

  • Create another data base of Liquibase changelog: automatic data type conversion

    I need to convert the structure of PostgreSQL databases to Oracle. In PostgreSQL, I a postgres database.

    In Oracle, I have an empty database in which I want to write to postgres database in PostgreSQL.

    Actually, I didn't need the data, only the structure (relationships).

    For this, I use Liquibase. I get the changelog of PostgreSQL with the command:

    Liquibase.

    -driver = org.postgresql.Driver.

    --classpath="C:\db_drivers\postgresql-9.3-1102.jdbc3.jar------.

    --changeLogFile="./postgresql_changelog.Xml------.

    -url = "" jdbc:postgresql://localhost:5432 / postgres "\"

    -username = schema_name_here.

    -password = *.

    -logLevel = debug.

    -defaultSchemaName = Ms.

    generateChangeLog

    After that, I try to create objects in the Oracle database:


    Liquibase

    -driver oracle.jdbc.OracleDriver =

    --classpath="C:\db_drivers\ojdbc14.jar".

    --changeLogFile="./postgresql_changelog.xml".

    --URL="JDBC:Oracle:thin:@ip_here:orabeta".

    -username = *.

    -password = *.

    Update

    Does not work: ORA-00902

    Here is a fragment of postgresql_changelog.xml:

    ...

    < changeSet author = '(generated) Alexey' id = "1409146335011-53" >

    < create table tableName = "TABLE1A" >

    < column name = "total_pk" type = 'INT8' >

    < forced nullable = "false" / >

    < / column >

    < column name = "form_fk" type = 'INT8' >

    < forced nullable = "false" / >

    < / column >

    ...

    I also generate a pure SQL file:


    Liquibase

    -driver oracle.jdbc.OracleDriver =

    --classpath="C:\db_drivers\ojdbc14.jar".

    --changeLogFile="./postgresql_changelog.xml".

    --URL="JDBC:Oracle:thin:@ip_here:orabeta".

    -username = *.

    -password = *.

    updateSQL > update.sql

    Here is a fragment of update.sql:


    ...

    CREATE THE TABLE SCHEMA_HERE. TABLE1A (total_pk form_fk INT8 INT8 NOT NULL,.. .etc);

    INSERT INTO SCHEMA_HERE. TABLE1A (ID, $form_id,... etc.)

    ...

    I want to generate the file, in which all the data types correspond to the target database, that is to say I want to create. I can write a simple parser that replace the data types, but this isn't the right solution - can be a lot of data.

    It is possible to get changelog from a database and update another database on a different server this changelog RDBMS? I need to get the automatic and Automatic data type conversion generate XML data / SQL output with the data types of target database.

    Or maybe there is an option to generate output data types with "abstract"? That is to say with data types that are not in the actual databases, for example, instead of INT8 - whole, etc.

    I would be very grateful for the information. Thank you all.

    Why not to use pg_dump to extract the schema in a file of script that you can then 'change '?

  • Problems with the Long data type conversion

    With the help of Oracle 11 G.

    I have a vision where one of the name of the column is of type long, I need to convert in varchar2. I tried using the to_Lob() function, but this error:

    ORA-00932: inconsistent data types: expected - got LONG

    I followed this article (step 1), which suggests to use to_lob()

    My query is:
    select
    item1, -- this is of type LONG
    item_vat, 
    price_pc_tot,
    from xd_item_price_view 
    I tried to convert it into:
    select
    to_lob(item1) as item1_x, -- this is of type LONG
    item_vat, 
    price_pc_tot,
    from xd_item_price_view 
    I am confused about the "-", why he would expect that? Thanks for watching it.

    >
    Sorry mate, just realized that. Yep, this is the one I followed (step 1 using to_lob())
    >
    It's a case of 'use' along in a query or search.

    But you can use to_lob as part of creating a new table.

    Response to see Dom Brooks in this thread
    Re: Conversion long to varchar2

    And he directly answered your original question
    >
    But you can't use TO_LOB in a statement SELECT right:

  • DATE in TIMESTAMP data type conversion

    Hello

    My question is this:

    1. I have a variable of type DATE, which I attribute the value of SYSDATE
     mydatevar DATE:= SYSDATE;
    2. I want to find * «today» *, truncated to DATE
      TRUNC (mydatevar, 'DD')
    TRUNC function returns the DATE data type. So I get to the point for example 2 *'2010-01-13 00:00:00 ' *.

    3. I want to assign the value of the point 2, to a variable of type TIMESTAMP
      mytimestampvar TIMESTAMP := mydatevar;
    implicitly that will convert the variable DATE to TIMESTAMP.

    Problem: when converting (implicit and explicit conversion with a format mask), I lose hours "00" and "00" minutes and receive something like this: "10 January 13 * 12 *. 00.00.000000000 AM.

    Question: How can I convert a DATE to TIMESTAMP keeping the hours and minutes zeros?

    Why I need this conversion: I have a table with one "column1" TIMESTAMP column (0) and I take only the rows of the table, where 'column1' is in the range of today 12:00 in the morning until now (what time it is).

    Features of the database NLS:
    PARAMETER                           VALUE
    NLS_LANGUAGE                           AMERICAN
    NLS_TERRITORY                   AMERICA
    NLS_CURRENCY     $
    NLS_ISO_CURRENCY                    AMERICA
    NLS_NUMERIC_CHARACTERS     .,
    NLS_CHARACTERSET                    AL32UTF8
    NLS_CALENDAR                            GREGORIAN
    NLS_DATE_FORMAT                    DD-MON-RR
    NLS_DATE_LANGUAGE            AMERICAN
    NLS_SORT     BINARY
    NLS_TIME_FORMAT                     HH.MI.SSXFF AM
    NLS_TIMESTAMP_FORMAT             DD-MON-RR HH.MI.SSXFF AM
    NLS_TIME_TZ_FORMAT             HH.MI.SSXFF AM TZR
    NLS_TIMESTAMP_TZ_FORMAT     DD-MON-RR HH.MI.SSXFF AM TZR
    NLS_DUAL_CURRENCY              $
    NLS_COMP                             BINARY
    NLS_LENGTH_SEMANTICS               BYTE
    NLS_NCHAR_CONV_EXCP             FALSE
    NLS_NCHAR_CHARACTERSET     AL16UTF16
    NLS_RDBMS_VERSION             10.2.0.4.0
    Session settings are the same.

    DBTIMEZONE is "+ 02:00".

    Verdi wrote:
    Problem: when converting (implicit and explicit conversion with a format mask), I lose hours "00" and "00" minutes and receive something like this: "10 January 13 * 12 *. 00.00.000000000 AM.

    I don't think you lose necessarily any information whatsoever. It is probably more a function of your NLS_TIMESTAMP_FORMAT and NLS_DATE_FORMAT. For example, your NLS_DATE_FORMAT could be default setup for a HH24 (24 hours) which would report to midnight as hours of "00". However, it seems that your NLS_TIMESTAMP_FORMAT is configured with "HH" format with a Meridian indicator that means 12 hours time.

    Your comparisons should use date/timestamp data types anyway, so as long as the input value is correctly converted to date type that shouldn't matter in any case.

    You can see what is actually stored by using the DUMP function:

    SQL> SELECT  DUMP(TO_TIMESTAMP(TO_CHAR(TRUNC(SYSDATE,'DD'),'MM/DD/YYYY HH:MI:SS AM'))) AS TSTAMP
      2  ,       DUMP(TRUNC(SYSDATE,'DD')) AS DT
      3  FROM DUAL
      4  /
    
    TSTAMP                                                                      DT
    --------------------------------------------------------------------------- --------------------------------------------------
    Typ=187 Len=20: 218,7,1,13,0,0,0,0,0,0,0,0,0,0,3,0,0,0,0,0                  Typ=13 Len=8: 218,7,1,13,0,0,0,0
    

    As you can see the TSTAMP and DT store almost the same values (218,7,1,13), but the TSTAMP has more precision because of fractions of a second.

    HTH!

    Published by: Centinul on January 13, 2010 07:23

  • Variant data type conversion

    Hi all

    I use VI Scripting in LabVIEW 2010. I need to know the data type of the wire connected to a Terminal. Terminal wire reference gives a property called "Datatype". I thought that this will help me. But he is a variant and how do I actually convert the data to find out the data type. Specifically, I want to make use of data type of cluster. How do I know if the wire is of type cluster?

    Thanks for any help.

    You want to use the 'GetTypeInfo.vi' VI "LabVIEW 20xx\vi.lib\Utility\VariantDataType\" folder for this!

    I would recommend installation of this Package of VI because it adds these features to pallets:

    https://decibel.NI.com/content/groups/hidden-gems-in-vilib

    Here's what it looks like:

  • Conversion of the data type of a table column

    Hello

    I have a column with the varchar2 data type. I want to convert to number data type. But the data in the table are not lost. Can someone suggest me how to convert the column with the varchar2 data type to store the data in the table of number data type.

    Thanks in advance

    try something like this

    create table t(col varchar2(10));
    insert into t values('1');
    insert into t values('2');
    commit;
    select * from t;
    alter table t add  col1 number;
    update t set col1 = to_number(col);
    commit;
    alter table t drop column col;
    alter table t rename column col1 to col;
    select * from t;
    

    Published by: Karthick_Arp on April 6, 2009 12:32 AM

  • data type conversion error

    Hello
    I have the insert under certain conditions
    insert into temp1(no number) 
     SELECT (CASE WHEN TO_NUMBER(TO_CHAR(SYSDATE,'DDMMYYYY')) BETWEEN                                 TO_NUMBER(TO_CHAR(START_DATE,'DDMMYYYY')) AND
             TO_NUMBER(TO_CHAR(END_DATE,'DDMMYYYY'))
            THEN NVL(ORG_ID,0) ELSE 0 END)
    FROM temp2;
    but get the following error:

    ERROR at line 3:
    ORA-00932: inconsistent data types: expected TANK got the NUMBER


    could you please give hint to resolve this error:

    Josh

    If your arguments start_date and end_date DATE data type, then you can simply use TRUNC

    INSERT INTO temp1(no)
    SELECT CASE WHEN TRUNC(sysdate) BETWEEN TRUNC(start_date) AND TRUNC(end_date)
                 THEN NVL(TO_NUMBER(org_id),0)
                ELSE 0
           END
      FROM temp2
    
  • MSSQL gateway nvarchar data type conversion

    Hello

    is there a way how to configure the MSSQL gateway to convert the data type nvarchar MSSQL in varchar2 Oracle instead of nchar? Because when converted to nchar, extra spaces are added as nchar is fixed-length, even if I load the data in varchar2 columns.

    Thanks for help
    Petra

    Not sure, but it looks like you're talking about Oracle TG4MSQL V10.

    Please be aware that all versions of TG4MSQL until V10.2 were desupported by March 15. Thus no additional code changes is made for V10 and frees up the bridge earlier. Customers have to migrate their gateway to the V11 DG4MSQL product that is now available for many platforms of follow-up.
    This DG4MSQL also has a mapping to change nchar/nvarchar/ntext data types, the extract of the manual here:
    -> NCHAR NCHAR
    NTEXT-> LONG (if the Oracle DB character set = Unicode. Otherwise, it is not supported)
    NVARCHAR-> NVARCHAR
    Nvarchar (max)-> LONG (if the Oracle DB character set = Unicode)

    Thos V11 gateways are certified with Oracle V9.2.0.8 database versions, 10.1.0.5 and 10.2.0.3 with a compatibility patch but in most applied to the database. This patch is already included in the 10.2.0.4 patches group.
    Database v11 works right out of the box.

  • issues of data type of waveform in labview

    Hello! IM creating an osciloscope in labview, but im having problems try to get a few items in waveform.

    I need to get items such as the XSCALEMAXIMUM to the type of waveform data (dark brown) not on DBL (orange).

    I already watch every single video on youtube and also gone thorugh many forums. but I still don't know how to get the data type of waveform elements.

    When I give graphics right click on wavefirn and select Create > property node > Y sacle > range > all items, if what I get

    but I need for this .

    This is what im trying to do im I can't see any conversion attempt.  then TI loks like its an option that I have not available or so.

    helpe me please!

    If you connect a waveform to a graph and then create a node property, you will get the type of waveform. If you have a connected DBL and create a node property, you will get the type DBL. Simple as that.

  • queues the IMAQ image data type

    I'm trying to run multiple queues in the same loop entering IMAQdx images from several cameras, and then save to AVI. After reading the site nor a little, I discovered that the reason why I get only the last image of each bucket, repeated on all frames in the AVI file, is that the IMAQ image data type stores only the memory location for the image, not the image itself data. However, I don't see a better solution for the queues of the actual image data. What conversion could be the fastest / are in charge of the processor the lowest?

    For each image you must initial Image space.

    You can use something like this:

    You need to add initialization camera (s) and AVI. You must add the multicamera feature. Stop recording is missing.

    !!! Don't forget to throw lines and Images!

  • What is the impact of the use of a variant on the performance data type, speed memory applications etc.?

    This is one of my sons "allows to get this settled once for all".

    I avoided data types variant when it is possible to track the performance of my apps. Some observatsions, I made over the years, I believe that;

    (1) operations in place cannot carry on variants.

    (2) in the way of a Variant to a sub - VI (regardless of the terminal on the connector of the icon) are always copied.

    I would like confirmation or correction of the foregoing order of we know better this animal we call LabVIEW.

    Thank you

    Ben

    Ben wrote:

    This is one of my sons "allows to get this settled once for all".

    I avoided data types variant when it is possible to track the performance of my apps. Some observatsions, I made over the years, I believe that;

    (1) operations in place cannot carry on variants.

    (2) in the way of a Variant to a sub - VI (regardless of the terminal on the connector of the icon) are always copied.

    I would like confirmation or correction of the foregoing order of we know better this animal we call LabVIEW.

    Thank you

    Ben

    I check I can pass a Variant to a Subvi with a copy, but it is still impossible to do something (scaling limit controls etc.) with a Variant without first copying it in a new buffer the conversion 'of the Variant.

    Thus,.

    For large sets of data, the variants are a bad idea.

    Ben

  • How to convert an array of string elements to a cluster with elements named different data types?

    I'm looking for more help with the conversion of an array of elements of the chain in a cluster containing elements named different data types.

    I am importing data from an Excel worksheet.  He is coming in LabVIEW as separate (channels) 3 tables: 1) Variable name, (2) three possibilities Int, double, String) data type and the value 3), with the clues in each table corresponding to a separate variable (I have about 180 variables to import).  My ultimate goal is to convert the string array of 'Value' in a cluster.  But I want the correct data type in the cluster and I also the elements of the cluster name to match with the string 'Variable name' table so that I can use the Unbundle based on the name in my main VI.

    Please see attachment a Subvi for more details.  I did the size of the new items of tables 5 for simplicity.   I realize that labels property cannot be changed during execution and I don't think I need to do.  I just want to use the production cluster (mainly the unbundle by name) to help design my main VI.  I will need to 'read' and 'write for' the cluster during execution, but I won't need to change the names of the items.

    I was also wondering if there is a better way to import data from Excel?  Is it possible to import directly into a cluster immediately rather than put everything as strings?  I have attached a Subvi showing how I currently bring in data (found on the forum somewhere).  It comes as table 2D, which I divided into 3 separate tables that I mention above.

    I am open to any suggestion.  Thank you very much.

    -Mike

    Instead of trying to create a cluster, I think I would use only variant attributes.

  • Change the Data Type to node e/s on PXI-7841R FPGA

    I would like to change the data type for the node FPGA of e/s on my card FPGA 7841R (simulation). So far, I have raw data (I16). I want to test something with the calibrated data (FXP).

    The cRIO, you usually go to the properties of module to change the calibration mode...

    I searched 7841R documentation and could not do any weather information this calibration mode was also available on this map.

    Any tips?

    Vincent

    The new maps in the series R offer node fixed point IO (for example, the SMU-7858R), but as mentioned all the old PXI based cards R-series offer only modes of measurement I16.

    Page 22 manual R series is about how to do this conversion: http://www.ni.com/pdf/manuals/370489g.pdf#page=22

    Specifically, it notes that you can calculate the voltage by (output Code I16) * 10.0V / (32 768).

    Even if this can use FPGA resources, it records the host do the same conversions. RT old target with slow processors doing the conversion of I16 or FXP to SGL on the FPGA has saved a lot of time CPU

Maybe you are looking for

  • Cookies active according to Firefox - but not true

    In attempting to create a sync account and receiving the message "Cookies disabled", I made the help instructions to erase the cache, cookies and history, but it does not work. I updated Firefox twice, wiped out at least three times and always in vai

  • How to stop calendar notifications that are not allowed?

    I created several events that repeat daily.  They are the hours and the price of admission to all the museums in my area.  I have no alarm on all calendar events yet I continue to receive notifications x Museum is open to the notification Center.  Us

  • Can I download the last FF with W98, then on a CD and then install from the CD on a Windows7 machine?

    Just bought a new machine Win7 and am waiting for connection to broadband. Installed a modem in the new machine, but the download speed is of about 1/4 of that of my old faithful W98SE machine. Can I use my W98 machine to download the latest files to

  • Satellite L745 - how to remove the keyboard safely?

    Hello, people! I need help please. As the topic says, how to remove the keyboard?It's because I shared tea on my keyboard and, fortunately, no key was damaged. However, now it is sticky, and it is quite annoying! Can someone please help me with the e

  • Error Msg: Local Area Connection network cable unplugged

    I'm installing Wi - Fi at home and continue to operate in the above msg.  I have wireless but I can't connect to internet at the "another computer" - not the host computer.  New router and adapter, double checked connections and have all the lights g