Home » SQL & PL/SQL » SQL & PL/SQL » Getting Error when using to_char function
Getting Error when using to_char function [message #218059] Tue, 06 February 2007 10:58 Go to next message
world.apps
Messages: 70
Registered: January 2007
Location: Hyderabad
Member
Hi,

I am trying to get the number of the day from the fallowing sql command by using to_char function.

Can't we use a particular date behalf of sysdate?


SQL> SELECT TO_CHAR('05-JUN-04', 'D') FROM DUAL;
SELECT TO_CHAR('05-JUN-04', 'D') FROM DUAL
               *
ERROR at line 1:
ORA-01722: invalid number

Thanks in advance







Re: Getting Error when using to_char function [message #218060 is a reply to message #218059] Tue, 06 February 2007 11:08 Go to previous messageGo to next message
BlackSwan
Messages: 25036
Registered: January 2009
Location: SoCal
Senior Member
Because '05-JUN-04' is a STRING; as is any collection of characters surrounded by single quote marks.
Re: Getting Error when using to_char function [message #218084 is a reply to message #218059] Tue, 06 February 2007 14:47 Go to previous messageGo to next message
MarcL
Messages: 455
Registered: November 2006
Location: Connecticut, USA
Senior Member
Try something like

SELECT TO_CHAR(TO_DATE('05-JUN-04', 'DD-MON-RR'),'D') FROM DUAL;


Re: Getting Error when using to_char function [message #218161 is a reply to message #218084] Wed, 07 February 2007 01:00 Go to previous message
world.apps
Messages: 70
Registered: January 2007
Location: Hyderabad
Member
I got it.

Thanks.
Previous Topic: Problem with the procedure which is using dbms_sql
Next Topic: no output
Goto Forum:
  


Current Time: Sun Dec 04 22:31:36 CST 2016

Total time taken to generate the page: 0.10852 seconds