Solved

ORA-01722: invalid number

Posted on 2010-11-18
5
1,819 Views
Last Modified: 2013-12-07
why am i getting this error?
select to_char('10/15/2010 11:07:20 AM', 'mm/dd/yyyy hh:mi:ss AM') from dual;

ORA-01722: invalid number
0
Comment
Question by:gram77
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
  • 2
5 Comments
 
LVL 77

Accepted Solution

by:
slightwv (䄆 Netminder) earned 500 total points
ID: 34164177
you need to use to_char with a date not a raw string.

select to_date('10/15/2010 11:07:20 AM', 'mm/dd/yyyy hh:mi:ss AM') from dual;

0
 
LVL 1

Expert Comment

by:Lacca
ID: 34165248
Because '10/15/2010 11:07:20 AM' already is a char.

Worging Examples:

convert chat to date
select to_date('10/15/2010 11:07:20 AM', 'mm/dd/yyyy hh:mi:ss AM') from dual;

convert date to char
select to_char(SYSDATE, 'mm/dd/yyyy hh:mi:ss AM') from dual;

0
 
LVL 77

Assisted Solution

by:slightwv (䄆 Netminder)
slightwv (䄆 Netminder) earned 500 total points
ID: 34165300
>>Because '10/15/2010 11:07:20 AM' already is a char.

To further clarify:  Actually you can call to_char with a char.

"select to_char('10/15/2010 11:07:20 AM') from dual;" will run just fine.  The invalid number error comes from Oracle dates being stored internally as a number and the to_char call referenced is expecting an Oracle date, a number, as the first parameter.
0
 
LVL 1

Expert Comment

by:Lacca
ID: 34171556
>>"select to_char('10/15/2010 11:07:20 AM') from dual;"

But what is the purpose of doing this?

0
 
LVL 77

Expert Comment

by:slightwv (䄆 Netminder)
ID: 34172599
>>But what is the purpose of doing this?

There would be no purpose.  I was just stating that the error wasn't caused by "Because '10/15/2010 11:07:20 AM' already is a char".  It was caused because '10/15/2010 11:07:20 AM' was not a number.
0

Featured Post

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Checking the Alert Log in AWS RDS Oracle can be a pain through their user interface.  I made a script to download the Alert Log, look for errors, and email me the trace files.  In this article I'll describe what I did and share my script.
When it comes to protecting Oracle Database servers and systems, there are a ton of myths out there. Here are the most common.
This video explains at a high level about the four available data types in Oracle and how dates can be manipulated by the user to get data into and out of the database.
This video shows how to Export data from an Oracle database using the Original Export Utility.  The corresponding Import utility, which works the same way is referenced, but not demonstrated.

751 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question