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}

Tags: Database

Similar Questions

  • date format conversion

    Hello

    I have the date format in the table as below and now I need to convert the date format YYYY-MM-DD hh: mm :)

    data type of column is varchar2 (20)

    1993-06-24 - 14.15.06.785408 (note: hours, minutes, seconds, milliseconds are separated by.) (dot)

    1991-11-05 - 11.32.17.045702

    Can someone help me please.

    Thank you!

    Hello

    3058870 wrote:

    Hello

    I have the date format in the table as below and now I need to convert the date format YYYY-MM-DD hh: mm :)

    data type of column is varchar2 (20)

    1993-06-24 - 14.15.06.785408 (note: hours, minutes, seconds, milliseconds are separated by.) (dot)

    1991-11-05 - 11.32.17.045702

    Can someone help me please.

    Thank you!

    Do not store information on dates in a VARCHAR2 column. It's simply to request data not valid, complicated, inefficient code and runtime errors.  The columns DATE, or, if necessary, fractions of a second TIMESTAMP.

    To convert strings from one format to another, you can always use TO_DATE to convert any format they are dates and then use TO_CHAR to generate a new string, in any desired output format.

    In this case, it seems that you just want to lose the split second, change the 3rd indent to a space and change points to colons.  You can do the following:

    SUBSTR (datatype, 1, 10).

    ' '                      ||

    REPLACE (SUBSTR (datatype, 12, 8)

    , '.'

    , ':'

    )

    If you would care to post CREATE TABLE and INSERT statements for some sample data and accurate results, you want from these data, then I could test this.

    Check out the Forum FAQ: Re: 2. How can I ask a question on the forums?

    You could do all the work in a single call REGEXP_REPLACE, but it is probably more complicated and less effective.

  • How do I change the date format in the section of the United States to the United Kingdom

    As in the question.

    Hello

    I had a glance in this and have found that Thunderbird uses the date format of your computer system. If you change it, it should be reflected in Thunderbird.

    I hope this helps, but if not, please come back here and we can look at another solution for you.

  • 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

  • What is the date format used in the charts of Microsoft Support policy? Is the day/month/year or month/day/year?

    For example, the Date of beginning of life cycle shows 31/05/2001 (March 5) and the end of Support Date extended watch 07/12/2001 (12 July or December 7).

    The date format is month/date/year. This format is for the start date and end date for extended Support.
    In your example, the start date is May 31, 2001, and the end date would be July 12, 2001.

    I hope this helps.

    Marilyn

  • 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. MinValue?

    How can I change the date format. MinValue?

    If you get any solution for this, a work around you can try and update us if it works or not:

    Go to your date attribute in DataControls.dcx (you must first select the control of your data)

    You may need to click on change icon to open the XML.

    Under guidance UI do following changes:

    Type of format - Format of Date Simple

    -The format DD/MM/YYYY

  • 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

  • How to change the date format in Lightroom, when importing images?

    When you import into Lightroom, you get the following structure in Lightroom for Macintosh HD.

    Year-> Date.

    I want some level 3 like this structure.   Year-> month-> Date

    How to do this?

    Hi lennartr,

    When you import images, you can change the Date Format in "Copy as DNG, copy or move", but not in the Add box.

    On the right panel, you expand the Destination folder and change the Date Format.

    Let me know if it helps.

    Kind regards

    Tanuj

  • Options for PDF export - how to change the date format?

    Hello


    I use Adobe InDesign CC June 2015 on Windows 7.

    When I export a PDF file to print, the date and the format is ' mm/dd/yyyy' (e.g. 2015/12/11 15:14:21) but I want to be ' dd/mm/yyyy' (for example 12/11/2015-15:14:21).

    I know it's possible because my colleagues have this date format on their PDFs.

    Do you know where I can change this option?


    Thanks in advance,

    Kind regards

    Julie

    Well, if the version of your indesign is french you must change the date format in system preferences

    to take a peek here how you can do

    Change the Format of Date under Windows 7, 8.1 and Windows 10 in dd-mm-yyyy

  • I did a blog in adobe muse and his now adjust it in British Colombia, but I can't seem to change the date format of blog post?

    I did a blog in adobe muse and his now adjust it in British Colombia, but I can't seem to change the date format of blog post?

    My ideal date format would be / 28, Oct 2015

    can anyone help? I don't know that I can handle the {tag_postdate}

    You can use something like this in the post or poster list: {tag_blogpostday}, {tag_blogpostmonth}, {tag_blogpostyear}

  • How to get the Date format for a specific date?

    May be it is inept to ask, but I'm aware of the Date.
    which appear on client - it's just that the average customer treats the date.
    Right?
    So what happens if a need to check the format to set the server to date.
    Or need to write common code indicating the date format
    on the server, it is running.

    This requirement came into my mind while using the extract method.
    Actually, I wanted to date of manipulation of the side back end.
    Let's say the time is 04:12:2012 03:05:16.
    Now, if I add 100 minutes, the result will be.
    04:12:2012 04:45:16.

    It's the requirement. Maybe there may be best way to do
    but it's the way I think now.

    Thank you.

    It's something that you don't need to know:
    you have a string containing a date or timestamp, and then he must know the format of this string and not the fornat date used by the server.
    or you have a date or timestamp, and then you can add minutes to it without knowing the format as described before.

  • Get the Date format that the user sets in "Preferences".

    Hello
    Is it possible that I can get the date format (for example: "DD-MMM-YYYY', 'DD-MM-YYYY' etc.) where the user desires under 'Préférences' in a page of the OPS?

    Concerning
    Hawker

    Published by: HawkerHunter on Aug 6, 2011 11:02

    ICX_DATE_FORMAT_MASK - is the value of profile that contains the value that is selected in the preferences page.
    You can try pageContext.getProfile ("ICX_DATE_FORMAT_MASK");
    in your code.

    Kind regards
    Krishnan guru.

  • 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

  • The date format custom - every time? JJ/mm/AA

    I'm ding my first form biggish so there is a list of questions, I am trying to solve here, bear with me...

    I'm in europe and we like the date format jj/mm/aa, but this is not a default option to choose so I have to put in custom, jj/mm/aa every time I want a date field. I have about 12 per form at the moment so is there any way for Acrobat to "remind", even within the document, regardless of the 'preferences' for the entire program. I can't find anything under the tongue or international options.

    Thank you

    Matt

    After this setting, right-click the field and select "use current properties.

    as the new default values".

Maybe you are looking for

  • Time Machine - how to change discs

    Hello Until now, I had time Machine using external HD_1 external drive. I just bought a new drive, external HD_2. I'd like Time Machine to begin to use external HD_2 while the addition of new backups to existing backups database. My question is: How

  • Example: Pavilion 500_402ND: keyboard

    keyboard does not work as I try to put in letters

  • Is it possible to spend in Firefox 4 on a machine running Mac OS 10.4.11?

    I can't upgrade my OS as our machines (Mac mini with 1 GB of RAM) do not have CPU Pentel needed for the OS 'Snow Leopard', and although I can DL the installation of programs for FF4, I am prevented from dragging and dropping them in my Applications f

  • G4 250: lack of drivers

    Hello Can anyone help please? At the school that I work, we bought 2 new HP 250 G4 notebooks. They came with Win 10, I had to change this for Win 7 via a complete reinstallation. However now that I did this there seems to be 2 missing drivers I can't

  • new operating system

    I have a toshiba laptop. The drive stop working so I bought a new. So now I don't have an operating system. I was wondering if it would be possible to get a copy of Windows I was running to get back on my computer.