Solved

ORA-01722: invalid number

Posted on 2010-11-18
5
1,763 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
  • 3
  • 2
5 Comments
 
LVL 76

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 76

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 76

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

PRTG Network Monitor: Intuitive Network Monitoring

Network Monitoring is essential to ensure that computer systems and network devices are running. Use PRTG to monitor LANs, servers, websites, applications and devices, bandwidth, virtual environments, remote systems, IoT, and many more. PRTG is easy to set up & use.

Question has a verified solution.

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

Suggested Solutions

Working with Network Access Control Lists in Oracle 11g (part 1) Part 2: http://www.e-e.com/A_9074.html So, you upgraded to a shiny new 11g database and all of a sudden every program that used UTL_MAIL, UTL_SMTP, UTL_TCP, UTL_HTTP or any oth…
Configuring and using Oracle Database Gateway for ODBC Introduction First, a brief summary of what a Database Gateway is.  A Gateway is a set of driver agents and configurations that allow an Oracle database to communicate with other platforms…
Via a live example show how to connect to RMAN, make basic configuration settings changes and then take a backup of a demo database
This video shows syntax for various backup options while discussing how the different basic backup types work.  It explains how to take full backups, incremental level 0 backups, incremental level 1 backups in both differential and cumulative mode a…

911 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

Need Help in Real-Time?

Connect with top rated Experts

20 Experts available now in Live!

Get 1:1 Help Now