Play with the date format TO_CHAR

Hi all
I'm learning how function TO_CHAR date format and code using the table double, but I had a few difficulties:
SQL> select to_char(sysdate,'dl') test from dual;

TEST
-----------------------------
Monday, December 20, 2010

SQL> select to_char(sysdate) test from dual;

TEST
---------
20-DEC-10

SQL> select sysdate test from dual;

TEST
---------
20-DEC-10

SQL> select to_char('20-DEC-10','dl') test from dual;
select to_char('20-DEC-10','dl') test from dual
               *
ERROR at line 1:
ORA-01722: invalid number
How can I place an explicit function TO_CHAR date?

Best regards
Valerie

Valerie Debonair wrote:
Hi all
I'm learning how function TO_CHAR date format and code using the table double, but I had a few difficulties:

SQL> select to_char('20-DEC-10','dl') test from dual;
select to_char('20-DEC-10','dl') test from dual
*
ERROR at line 1:
ORA-01722: invalid number

How can I place an explicit function TO_CHAR date?

Oracle converts implicitly your string to a date so that it can convert it to a string using your to_char function. Implicit conversion is based on your NLS_DATE_FORMAT settings, but you can never count on these implicit conversions.

You can be...

SQL> select to_char(to_date('20-DEC-10','DD-MON-RR'),'dl') from dual;

TO_CHAR(TO_DATE('20-DEC-10'
---------------------------
Monday 20 December 2010

or

SQL> select to_char(date '2010-12-20','dl') from dual;

TO_CHAR(DATE'2010-12-20
-----------------------
Monday 20 December 2010

Note that this one used Oracle fixed-date internal format YYYY-MM-DD, so if ever you use this method, you must specify the date string in this format. It also only deals with dates, not the component "hour".

Tags: Database

Similar Questions

  • Comparing converted text until then with the Date column

    I have a question where I need out of a text column in a date format and then compare this column against another column in the same table, which is already to date format. I tried to use a sub query to avoid doing this in two steps, but get a:

    "ORA-01858' a non-digit character was found here where was waiting for digital"

    error message that obviously has something to do with the date formatting in the subquery: the types do not match.

    Note: clock_num is a text column and contains the numbers are supposed to be dates like 070111 - where the need for conversion to a date type to match the stat_date which is the type of date column. I have no control over the data in this column. It is not my picture, is the picture of the society and I have to use!

    So my question is what syntax/function should I use to get the type of expression clock_nbr the type of eff_date.

    Or y at - it another way to do the same thing without using subquery?

    Any help is appreciated...

    SELECT
    me. SSN,
    Of
    member_enroll me
    WHERE me.ssn = '999999999'
    AND me.stat_date <
    (SELECT to_date (substr (me.clock_num, 1, 2) |)) » /' || substr (me.clock_num, 3, 2) | '/' || substr(me.clock_num,5,2), 'mm-DD-yy') as clock_nbr
    OF member_enroll me
    WHERE me.ssn = '999999999')

    I have no experience with PL/SQL Developer. Any chance you could launch SQL * more and copy / paste of a session where you run this code?

    You should only run the DDL to create the function once. If the second query runs, you have managed to successfully create the function. My hypothesis is that whatever 'window SQL' you are talking about and what you mean by 'run' is the cause only the function must be created. Most of the IDEs have a function to execute current SQL statement, without taking into account other statements that can be registered in the same window, and a separate function to execute all instructions in the current window. Different iDEs have different requirements to separate several SQL statements if you want to run all of the SQL statements in a window. You may need to do something like the added statement a / after the CREATE FUNCTION as a separator.

    Justin

  • QSI CDRW/DVD SBW-242 won't read DVD or BURN a CD (music CD will PLAY) [AFTER the HD FORMAT and re - install}

    Dell Inspiron5100 WinXP SP3.

    Due to malware, I had to FORMAT my HD and re-install Windows XP OEM disc.  I also reinstalled WIN DVD4 from the OEM disc that came with the laptop.

    Check SYSTEM/DeviceMGR/material indicates a problem with the drive, but: it won't READ a DVD or burn a CD (which she has done before)

    Can't update anything of QSI as they were absorbed by COREL years.  No support available for WINDVD4

    When you try to run WINDVD4 with a DVD in the drive, I get a Popup of WINDVD screen that says:

    CREATE OVERLAY FAILED-Please lower your color depth or screen resolution and try again.  Of course, it worked fine with the reg settings in the past, now Ive tried even lower TWO the RES SCREEN and color at least registered but still does not work

    It WILL play CDs of music (mp3s)

    Found the following material etc.

    Provider: Microsoft Corp.

    File version: 5.1.2600.5512 (xpsp 080413-2108

    Driver date: 01/07/2001

    Driver version: 5.1.2535

    Driver files

    C\windows\system32\DRIVERS\cdrom.sys

    "" "" \DRIVERS\imapi.sys

    «"\DRIVERS\redbook.sys «»

    «"«\system32\ c:\windows\system32\storprop.dll»»»

    I installed and ran but it won't play MICROSOFT 'FIXIT' DVDs just run from WINDVD4 and still does not.

    FIXIT now brings me HERE

    It seems that FORMAT/reinstall has missed something the will allow the CD PLAYER of .1BURN and 2. READ the DVD, but allows you to PLAY CDs

    From: * e-mail address is removed from the privacy *.
    To: * e-mail address is removed from the privacy *.
    Date: Tuesday, May 17, 2011 08:30:29-0700
    Subject: QSI SBW 242 CDRW/DVD not play DVD or BURN a CD (music CD will PLAY) [AFTER the HD FORMAT and re - install}

    Response

    Hello

    1. are you able to read any type of file .doc or .txt of DVD?

    After following all the steps (including the update of the MP9 for Media Player [MP] 11) below

    I can get the drive to DISPLAY all the data from the DVD (Master & Commander 'movie)

    on-screen MP11.  He plays (automatically) the intro (ONLY) from the DVD music (as when you put it in a DVD player, forward to press PLAY) MP11 shows all of the content and all the files on the DVD and SEEMS ready to play, but pressing on PLAY don't either not anything.

    2 , what exactly happens when you try to burn the CD? You get the error message?

    Not nothing... He's here

    3. How do you try to burn CDs?

    MediaPlayer, selection of a track list, made a list of titles, and then click BURN... nothing happens

    4 have you tried to play the DVD content in ? windows media player

    I had not before, but now I have.  Previously it was default to my SELECTION WIN DVD4 as the DVD player (I think I've EVER SEEN the WINDVD format/start page on the front screen - it wasn't the default front DVD player either but don't remember what program PLAYS the DVD, he ' comes of ").  Now, go back and see 1. above for MP11 more details.

    Try to update the drivers of CD-RW/DVD drive and check. Also update the graphics driver.

    I did the entire bottom.

    1. click on Start, click Control Panel, and then double-click System.

    2 click on the hardware tab, and then click Device Manager.
    If you are prompted for an administrator password or for confirmation, type the password, or click continue.

    3 right-click on the CD-RW/DVD drive, and then select set to update driver.

    He asks if I have an OEM driver and / disk... NO.. I run the program through...

    "Hardware update Wiz can not find a better match the software installed"

    4. right click on the graphics card and select Update driver. »

    There is no "graphics card" on the material.  This machine has integrated graphics using a part of the main memory (or other) to run the video section:

    I find:

    AUDIO, VIDEO and GAME controllers (announcement)

    Audio codecs

    Audio drivers

    Legacy video capture device

    Media control devices

    Audio Sigma

    Video codecs

    All this seem normal but above I see YELLOW TWO warnings under 'OTHER DEVICES '.

    ?!  Ethernet controller "drivers for this divide (code28) is not installed.

    ?! VIDEO CONTROLLER (VGA Compatible) I didn't HAVE NO IDEA if THIS if APPLIES OR NOT

    Device type - other devices

    MFG-unknown

    Location PCI bus, device 0, function 0.  "Drivers for this device are not installed, CODE28 to reinstall the driver."

    Has been through the usual (request for drive... Laughing out loud. Impossible to beat")

    See also:

    How to troubleshoot common problems that occur when a Windows XP-based computer cannot read a CD or DVD

    http://support.Microsoft.com/kb/321641

    Did yesterday.  It installed/ran "MR. Microsoft Fixit' with the result:

    "Question: media in the CD-RW/DVD drive is not readable" CLICKED top DIFFICULTY... and after computer "worked" on this subject awhile, he says STATUS: fixed.  St ill did not.   MP9 introduced the format of the DVD player but don't seem to read anything other then showing a list:

    UNKNOWN

    Title 1

    Title2

    Title 3 etc., but could not do anything with this list.

    He appeared a box asking if I wanted to update my MP9... sure why not so I shut everything down and uninstalled 9 and installed Media player 11.

    Go BACK to # 1. now once again.  This is where I am.  MP11 shows all DVD data, the chart "the Album/DVD cover, all"titles"on the DVD, AND play the track audio 'intro' DVD but will not actually READ the DVD. "

    So far it's PROGRESS.  We are at a point where it SEEMS at least that we are ready to PLAY and MP can SEE all the info on the DVD.

    I see many people on other sites of the same question: Player does not work after FORMAT operating system and reinstall of WIN (and in my case: WinXP SP3 and WIN DVD4 of OEM disc)

    Thanks a lot for your help so far... I hope that we can get to the next step and get the reader of CD-RW/DVD on 'PLAY '.

  • Date formatting to_char - truncate issue zeros

    Hello

    I have used this date formatting in an APEX application, but I noticed that the problem also occurs when you run a simple script in the database.

    The query is:

    Select

    TO_CHAR (sysdate, 'fmDay, GFMD fmMonth AAAA HH:MIPM'),

    TO_CHAR (sysdate, ' HH:MIPM of MON-DD-YYYY "")

    of the double

    The problem occurs when the minutes have a zero in it, in the example that I have attached, it was 14:05, and it shows as 14:05

    https://plus.Google.com/u/0/photos/104459804528712563956/albums/5958573459391223345/5958573462256341170?PID=595857346225...

    Is there a reason that this is happening? I am unable to use the combination I've used? I really want the full date with month and day names.

    Version of DB: Oracle Database 11g Enterprise Edition Release 11.2.0.3.0

    Amanda.

    Just add fm with the time format:

    SQL > select

    2 to_char (sysdate, 'fmDay, GFMD fmMonth AAAA fmHH:MIPM')

    3 double;

    TO_CHAR (SYSDATE,'FMDAY, FMDDFMMONTHYY)

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

    Wednesday, December 18, 2013 09:03

    Concerning

    Girish Sharma

  • filling of datetime column SQL Server with the data in the date column oracle

    After a lot of "finangling", I think I have my link dg4msql works well between Oracle and MSSQL.

    Now, what I'm trying to do, is fill a table in MSSQL with an Oracle table column values, whenever a new row is inserted in the Oracle table. I use a very simple trigger on the oracle table that goes basically like this:

    mware is dblink to MSSQL database, oracle col worth DATE and mssql col is of type DATETIME

    This is the relaxation: (edited to show only the column in question)
    ==================================================================================
    CREATE or replace TRIGGER < oracleowner >. INSERT_INTO_NVDB
    AFTER INSERT ON < oracleowner >. < oracletable > for each row
    BEGIN
    insert into '< mssqlowner > '. «< mssqltable > @mware «»
    (
    "load_date_time,"
    )
    VALUES)
    : new.loading_date,.
    );

    END;
    ==================================================================================

    Now, when you enter a record in the Oracle trigger triggers ok table but does not insert a date in the MSSQL table, the 'load_date_time' in the mssql table can have NULL values so I guess there just inserts a null value.

    When I activate the triggers on the table MSSQL, which then takes these values and inserts them into another table with values from other tables, inserting in the Oracle table fails because the relaxation on the MSSQL database tries to pass the date (which is empty) table MSSQL in another table where the datetime field is not null.

    I guess it's because Oracle date format is not compatible with MSSQL, which I think is "yyyy-mm-dd hh: mm:"- so I have to either convert the date format by default Oracle to match a MSSQL, or convert a char of the trigger value. (The developer of the side MSSQL says if I can convert it to a char value that should be ok too)

    I think that it is probably better to leave it in the date format, the best way to do this would be to put an "alter session set nls_date_format ="at the beginning of the trigger?

    Can I convert the date to char the trigger easily? If there is a better way to proceed in the way I approach it I'm all for it.

    Thank you!

    Hello
    Your best option is to explicitly convert dates Oracle in a format recognized by SQL * Server. It's more coding, but then you know exactly what is being inserted and you give more control, if anything changes. You can also code to handle null data.
    I'm not sure than to try to change the format of date to 'alter session... ". "do what you want.
    You can use "to_char" on a date into character data-

    To_char (, "HH24:MI:SSxFF of MON-DD-YYYY")

    and use any mask format supported.
    You also use 'to_date' to transform the character data in a date format, as well as 'to_char' and 'to_date' in combination.
    For example -.

    SELECT TO_CHAR (TO_DATE (October 27, 98 ',' DD-MON-RR'), 'YYYY') 'Year' FROM DUAL;

    This is all discussed in the documentation-

    Oracle® database
    SQL language reference
    11g Release 2 (11.2)

    where it also describes the different format masks.
    If you need further assistance on the use of to_date, to_char formats then ask in the forum SQL/PLSQL.

    SQL and PL/SQL

    where they have more experience.

    Kind regards
    Mike

  • Problems with the date in the procedure on Oracle 11 g

    Hi gurus,

    I have some problems with the date under Oracle 11 g format.

    Let me explain the situation:

    When I start such a request
    Select to_number (to_char (to_date('01.04.2009','dd.mm.yyyy'), 'yyyy'))
    of sys.dual

    I had as a result 2009 under the number.

    When I do the same thing in a procedure of a package like this

    my_year: = to_number (to_char (to_date('01.04.2009','dd.mm.yyyy'), 'yyyy'));

    the my_year variable contains the value 9 instead of 2009.

    Can someone explain to me what goes wrong?

    I just tested with the evolution of the variable nls_date_format of environment for the session and the database is complete without success.

    Kind regards
    Björn

    Yes, it has everything to do with your environment settings.

    SQL> set serveroutput on;
    SQL>
    SQL> declare
      2    my_date date;
      3    my_zeitstempel varchar2(32767);
      4    my_tageswechsel float;
      5  begin
      6    my_zeitstempel := '01.03.1998 07:00';
      7    my_tageswechsel := .25;
      8    my_date := to_date (substr (my_zeitstempel, 1, 10), 'dd.mm.yyyy') + my_tageswechsel +1/24;
      9    dbms_output.put_line( my_date);
     10  end;
     11  /
    01-MAR-98
    
    PL/SQL procedure successfully completed.
    
    SQL> alter session set nls_date_format = 'dd.mm.yyyy hh24:mi:ss'
      2  /
    
    Session altered.
    
    SQL> declare
      2    my_date date;
      3    my_zeitstempel varchar2(32767);
      4    my_tageswechsel float;
      5  begin
      6    my_zeitstempel := '01.03.1998 07:00';
      7    my_tageswechsel := .25;
      8    my_date := to_date (substr (my_zeitstempel, 1, 10), 'dd.mm.yyyy') + my_tageswechsel +1/24;
      9    dbms_output.put_line( my_date);
     10  end;
     11  /
    01.03.1998 07:00:00
    
    PL/SQL procedure successfully completed.
    
  • See the time with the date in the cell?

    How do you not see time with the date in a cell? I tried all the settings I can find but without success.

    Using the numbers from version 3.6.2 (2577) - OS: El Cap 10.11.6

    I don't want to see that 12:00:00 AM

    Hi Russ,

    Inspector to format > cell, the parameters as shown below:

    Kind regards

    Barry

  • How canI change the date format of dd/mm/yyyy to dd/mm/yyyy in filed?

    I just got and try things my new Alcatel fire E with FirefoxOS (just updated) 2.0.0.0.

    It is usual in most operating systems to be able to customize the date and time (among others). After a few hours of unsuccessful fiddling with the phone and checking the various forums, I came to the conclusion that it is currently not possible on my phone with this version of FirefoxOS. Or did I just miss something?

    Achim

    Hi achim_59,

    I understand that you want to set the date format to display the jj/mm/aaaa on your Firefox OS device.

    This feature has been implemented in Firefox OS v2.1. Unfortunately, this feature is not available in v2.0:

    For other questions about the updates and implementation of your specific device features, please contact your device manufacturer, Alcatel.

    -Ralph

  • How can I change the date format in Thunderbird for the list of received messages?

    Through 19/02/2015 12:28, I received my email with this format. Since that time, all the date Watch column is the time, the date does not show. How to get back to the default time and date format?

    The default is to show all the time on messages from today, with the date and time on all the other messages.

    http://KB.mozillazine.org/Date_display_format

  • How can I fix the speakers on my Asus laptop? I played with the settings and accidentally deleted some functions.

    original title: speakers on windows 7

    How to fix speakers on my Asus laptop. I played with the settings and accidentally deleted some features and I can't restore it to its original.

    Can you help me with this problem?

    Thank you in advance.

    The best

    YinNooy

    Use system restore to go back to an earlier date at the beginning of the problem.  To run system restore, click Start-> programs-> Accessories-> System Tools-> system restore.  Click on the box that says show more restore points.

    I hope this helps.  Good luck.

  • How to change the Date format

    Hello

    I have a question, is it possible to change the date format of a date value that comes from the database, therefore with the settings on the computer?

    I use jdev 12 c with Oracle database

    Thank you

    Hello

    You can use af:convertDatetime to set the date.

    Ref:

    Andrejus Baranovskis Blog: Handling of Format of Date and links of the ADF

    http://jdevadf.Oracle.com/ADF-richclient-demo/docs/tagdoc/af_convertDateTime.html

    date format ADF

    Thank you

    Amey

  • Change the Date Format of the data in Excel

    Hello, my data is stored in an excel file. They are connected to the Warehouse Builder through ODBC.

    When I used an operator to change the format of a date column, I have an error which referred to ODBC.

    Someone know how I can change the date format of the data that are not initially stored in an oracle database in oracle,.

    but in an excel file.

    If you need to know anything else, please ask me. It is so important to me. Thank you.

    When you directly use the warehouse with MS Excel ODBC without the bridge builder, then send your question directly in the Warehouse Builder Forum:

    Warehouse Builder

    We are discussing only matters concerning Oracle gateways.

    Thank you

    Klaus

  • Need help with the data storage store, local array and network connections

    Need help with my ESXi 4.1 installation

    My hardware:

    I built a server with an Asus P6T whitebox, i7 920, 12 Gig RAM, NIC, Intel Pro1000 PT Quad, 3ware 9650SE-12ML with 8 1.5 TB SATA green in a raid 6 array gives me about 8 + TB with a spare drive all housed within a NORCO RPC-4220 4U Rackmount Server chassis.  I also have a 500 GB SATA drive which will hold the ESXi and virtual machines.

    The network includes a firewall, Netgear Prosafe FVS336G, GS724Tv of Netgear ProSafe 24 port Gigabit Managed Switch on a dhcp cable modem internet service provider.

    I also have 2 old NetGear SC101T NAS disks (4to) I want to connect to the system how some - at a later date have... data on them and want to transfer to the new storage array. I always looking into the question of whether they will work with ESXi 4.1, or I might have to only access it through Windows XP.

    My Situation:

    I have already installed ESXi 4.1 and vsphere client with no problems and it is connected to a dhcp cable internet service.  I've set up host via a dynamic DNS service name give me a static hostname on the internet.  I installed three machines to virtual OS successfully at the moment and now want to first start by creating a multimedia storage server which will use some of this new 8 TB array, then separate data storage for use with a web server small overhead storage and a backup.  It is a domestic installation.

    Help with the data store and network:

    I was doing some reading, because I'm new to this, and it looks like I'll probably want to set up my table via ESXi as a nfs disk format.  Now, the data store is usually in another physical box from what I understand, but I put my readers and ESXi all in the same box.  I'm not sure that the best way to put in place with grouped network cards, but I want to make this work.

    I understand that in ESXi 4.1 using iSCSi LUN must be less than 2 TB, but nfs - I should be able to add a bigger partition then 2 TB (for my multimedia) in nfs, right? or should I still add it separately as a separate 2 TB drives and then extend them to get the biggest space.

    Any suggestions or direct resources showing examples on how to actually add some parts of the table as data warehouses separate nfs.  I know that to go to the configuration tab, and then select Add to storage, and then select nfs. I have not my picture, but it's here that I don't know what to do because ESXi 4.1 system already has an address, should I put the same thing to the new data store array also (will it work?), and what should I use for the name of the folder and the store of data... just do something to the top.  I thought to later install Openfiler (for a multimedia storage using this table server) as a virtual machine, use the table with esxi so that I can access the same storage space with widows and linux-based systems.

    I also know I have to find a way to better use my quad nic card... put in place of virtual switches, grouping, etc HELP?

    Any direction, assistance, similar facilities to sample, suggestions or resources that would help would be great. I did a lot of hunting, but still a little confused on how to best to put in place.

    You must think of VMDK files of large databases with records of random size guest go read some data (a DLL or an INI file), maybe write some data back, then go read other data. Some files are tiny, but certain DLLs are several megabytes. It's random i/o all and heavy on the search time. IO Opsys is small random operations that are often sequential (go read data, write data, go read other data,...) so that deadlines are critical to the overall performance. That's why people say OPS are / s of reference and forget the MBs flow. The only time where you bulk transfers are when you read media (ISO files).

    Well, now forget all this. Actually the disk activity will depend on the specific applications (database? mail server? machines compiler?), but the above is true for boots, and whenever applications are idle. You should see the profile to know.

    RAID 10 is faster (and often more reliable) than RAID 5 or RAID-6 except in certain specific cases. In General RAID 10 is ideal for many random writes, since the calculation of parity for RAID-5 and - 6 adds to the overall latency between command and response - latency is cumulative if a little slow here and a little slow it adds up to a lot of overall slow synchronous especially with e/s on a network. OTOH RAID-5 and -6 can produce faster readings due to the number of heads, so you can use it for virtual machines that transfer bulk. Test. You may find that you need several different types subdashboards for best results.

    You said 3ware, they have some good grades on their site, but don't believe it. With my 9650 that I found myself with only a couple of their recommendations-, I put the (simple) table for allocation size 256 k, nr_requests at 2 x the queue_depth and use the planner date limit. I had the habit for the Ext4 file system formatted with stride and stripe-width synced to the table and used the options large_files with fewer inodes (do not use the huge_files option unless you plan to have single VMDK files in the terabyte range). Use a cache of great reading in advance.

    Virtual machines use VMDK files in all cases except raw iSCSI LUN that they treat native disks. VMDK is easier to manage - you can make a backup by copying the file, you can move it to a PC and load it into another flavour of VMware, etc. There could be some features iSCSI to your San as a transparent migration but nothing for me. NFS has less chatter of Protocol if latency lower times to complete an operation. NFS is good to read and write a block of data, that's all it boils down to.

    UPS is good, but it won't help if something inside the machine explodes (UPS does nothing if the PC power supply goes down). If the RAID card has an option for a battery backup module, so it can contain some writings in memory and may end up the disk i/o after replacing the power supply. 3ware also limits the types of caching available if help is not installed, and you get just the right numbers with the module.

  • varchar2 to the date format conversion

    I have converted the formats of date several times, but for some reason, I get an error invalid number when you try to convert a varchar2 column. I tried the to_char and to_date function and I get the same result. The column is a date and it is formatted like ME-DD-YYYY, but I want to change it to DD/MM/YYYY. My query is below:

    Select to_date('fccpdate','MM/DD/YYYY')
    of cc_class_scmast_v

    When I try to_date I get this:

    Error from the 1 in the command line:
    Select TO_DATE ('fccpdate ',' MON-DD-YYYY "") of cc_class_scmast_v, where fccpdate IS NOT NULL
    Error report:
    SQL error: ORA-01858: a non-digit character was found here where was waiting for a digital
    01858 00000 - "a non-digit character found here where was waiting for a digital".
    * Cause: Input data to convert using a date format model has been
    incorrect answer. The input data did not contain a number where is a number
    required by the format model.
    * Action: Fix the input data or the date format model to ensure that the
    elements correspond to the number and the type. And then try the operation again.



    When I try to_char I get this:

    Error from the 1 in the command line:
    Select TO_char ('fccpdate ',' MON-DD-YYYY "") of cc_class_scmast_v, where fccpdate IS NOT NULL
    Error report:
    SQL error: ORA-01722: invalid number
    01722 00000 - "invalid number."
    * Cause:
    * Action:


    I tried to remove the single quotes of my column and that does make a difference. Any help is appreciated.

    Hello

    housetiger77 wrote:
    I have converted the formats of date several times, but for some reason, I get an error invalid number when you try to convert a varchar2 column. I tried the to_char and to_date function and I get the same result. The column is a date and it is formatted like ME-DD-YYYY,

    If the column is a DATE, then it has the same format that all DATEs, which is nothing like 'DD-MON-YYYY '. Formats like which apply only to chains.
    Conversely, if it is in the format "DD-MON-YYY", then it is a string, not a DATE.

    but I want to change to DD/MM/YYYY. My query is below:

    Select to_date('fccpdate','MM/DD/YYYY')
    of cc_class_scmast_v

    To_date (x, "MM/DD/YYYY") tries to convert the string x in a DATE. Let's say it starts by taking the first 2 characters of x, for the month. The first 2 characters of 'fccpdate' are "fc", which is not a valid number (at least not in base 10), not to mention a number from 1 to 12, TO_DATE so will raise an error.

    When I try to_date I get this:

    Error from the 1 in the command line:
    Select TO_DATE ('fccpdate ',' MON-DD-YYYY "") of cc_class_scmast_v, where fccpdate IS NOT NULL
    Error report:
    SQL error: ORA-01858: a non-digit character was found here where was waiting for a digital
    01858 00000 - "a non-digit character found here where was waiting for a digital".
    * Cause: Input data to convert using a date format model has been
    incorrect answer. The input data did not contain a number where is a number
    required by the format model.
    * Action: Fix the input data or the date format model to ensure that the
    elements correspond to the number and the type. And then try the operation again.

    When I try to_char I get this:

    Error from the 1 in the command line:
    Select TO_char ('fccpdate ',' MON-DD-YYYY "") of cc_class_scmast_v, where fccpdate IS NOT NULL
    Error report:
    SQL error: ORA-01722: invalid number
    01722 00000 - "invalid number."
    * Cause:
    * Action:

    I tried to remove the single quotes of my column and that does make a difference. Any help is appreciated.

    It's a good first step. Literals are enclosed in single quotes are not identifiers (including the column names). "fccpdate" is the literal string of 8 characters containing 'f', ' c; Another 'c', 'p' 'd', 'a', 't' and 'e'. " fccpdate (without the single quotes) can be the name of a column.

    If fccpdate is a string, as July 18, 2012', then you can convert it to a DATE using TO_DATE.

    TO_DATE (fccpdate, 'DD-MON-YYYY')
    

    If you want to display a DATE in a particular format, use

    TO_CHAR ( d
            , f
            )
    

    where d is a DATE, and f is the format string. In this case, d is perhaps the TO_DATE expression above

    TO_CHAR ( TO_DATE (fccpdate, 'DD-MON-YYYY')
            , 'MM/DD/YYYY'
            )
    

    I hope that answers your question.
    If not, post a small example data (CREATE TABLE and only relevant columns, INSERT statements) for all of the tables involved and also publish outcomes from these data.
    Explain, using specific examples, how you get these results from these data.
    Always tell what version of Oracle you are using.
    See the FAQ forum {message identifier: = 9360002}

  • Change the DATE FORMAT in a data store

    I created a few projects with the help of a Teradata technology using tables that allow to CREATE_TARG_TABLE the Yes option.

    Model / data store, there are DATE fields, but I can't change the DATE FORMAT, change the field.

    When the process starts and creates the table in the database, create using FORMAT of DATE "AA-MM-DD" and I would like to create as "YYYY-MM-DD".

    Y at - it a step that I am doing wrong, to be able to change the DATE FORMAT?

    From already thank,

    Hello

    --> Physical Architecture topology--> Teradata--> data types, create a new data type (or modify the existing DATE data type), then set it to the desired format of the syntax 'Create Table' and 'Format data type accessible writable.

    That is to say DATE FORMAT "YYYY-MM-DD".

    Then all your tables created will use this format. (I just tested it, it works).

    Let us know if you have any problems.

    See you soon

    BOS

    Published by: Bos July 12, 2011 15:50

Maybe you are looking for