Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8905611
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T02:26:19+00:00 2026-06-15T02:26:19+00:00

I have a string column COL1 when I am doing this SELECT TO_CHAR(TO_DATE(COL1,’dd-mon-yy’), ‘mm/dd/yyyy’)

  • 0

I have a string column COL1 when I am doing this

SELECT TO_CHAR(TO_DATE(COL1,'dd-mon-yy'), 'mm/dd/yyyy')
FROM TABLE1

The data in COL1 is in dd-mon-yy, eg: 27-11-89 and 89 is 1989 but the select returns it as 11/27/2089.

I have to do an inner TO_DATE because if I don’t then I am getting an invalid number error (ORA-01722: invalid number)

How can show 1989 instead of 2089? Please help

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-15T02:26:21+00:00Added an answer on June 15, 2026 at 2:26 am

    The data in COL1 is in dd-mon-yy

    No it’s not. A DATE column does not have any format. It is only converted (implicitely) to that representation by your SQL client when you display it.

    If COL1 is really a DATE column using to_date() on it is useless because to_date() converts a string to a DATE.

    You only need to_char(), nothing else:

    SELECT TO_CHAR(col1, 'mm/dd/yyyy') 
    FROM TABLE1
    

    What happens in your case is that calling to_date() converts the DATE into a character value (applying the default NLS format) and then converting that back to a DATE. Due to this double implicit conversion some information is lost on the way.


    Edit

    So you did make that big mistake to store a DATE in a character column. And that’s why you get the problems now.

    The best (and to be honest: only sensible) solution is to convert that column to a DATE. Then you can convert the values to any rerpresentation that you want without worrying about implicit data type conversion.

    But most probably the answer is “I inherited this model, I have to cope with it” (it always is, apparently no one ever is responsible for choosing the wrong datatype), then you need to use RR instead of YY:

    SELECT TO_CHAR(TO_DATE(COL1,'dd-mm-rr'), 'mm/dd/yyyy')
    FROM TABLE1
    

    should do the trick. Note that I also changed mon to mm as your example is 27-11-89 which has a number for the month, not an “word” (like NOV)

    For more details see the manual: http://docs.oracle.com/cd/B28359_01/server.111/b28286/sql_elements004.htm#SQLRF00215

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have an SQL query like SELECT Col1, Col2 FROM Table1 UNION ALL SELECT
I have hibernate query as below: String mySql = SELECT S.col1, S.col2, T.col3, T.col4,
I have three tables table1, table2, table3 with col1, col2 and identity ID column.
I have a string column (Col1) in table (Tab1). I want to write a
I have string column with numbers in a datagridview.It is not bound, I would
I have a table A with the string-column a and a table B with
I have inserted string and integer values into dynamic columns in a Cassandra Column
I have following code for updating user's column public void UpdateLastModifiedDate(string username) { using
I have mysql table that has a column that stores xml as a string.
I have a DataTable object. Every column is of type string. Using LINQ, how

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.