You are here:

Oracle/Invalid Number while using to_char date and group by of same column

Advertisement


Question
Hi Suchitra, I have been reading your answers. All you guys are doing a great service. Thanks a lot.

I am running the following query,

select count(*),
to_char('SOME_DATE,'dd-mon-yyyy')
from SOME_TABLE
group by
to_char('SOME_DATE','dd-mon-yyyy')

I get this error message INVALID NUMBER ORA-01722.

I am stuck with this, Please help me to get over this.
The data type for the date column in DATE.

Even if i try a simple

select to_char('SOME_DATE','dd-mon-yyyy') from SOME_TABLE,
I get the same error message. Please advice.


Answer
Hi Raghavendran,

If the SOME_DATE column is a date column, then it should not be given in single quotes (since you are using to_char function).

So try removing the single quotes around SOME_DATE column.

Hope this helps.

Regards

Suchitra

Oracle

All Answers


Answers by Expert:


Ask Experts

Volunteer


Suchitra Joshi

Expertise

I can answer questions regarding SQL, PL/SQL, Procedures, Functions, Triggers, SQL Loader, Oracle Forms, Oracle Reports, and some basic dba and performance tuning activities.

Experience

15+ years of Oracle PL/SQL Development

Education/Credentials
B.Sc (Electronics), Diploma in Computer Applications (DCA)

Awards and Honors
Oracle PL/SQL Developer Certified Associate (OCA)
Oracle Database: SQL Certified Expert
Brainbench certifications in Oracle Administration, PL/SQL, Developer 2000

©2012 About.com, a part of The New York Times Company. All rights reserved.