SQL Language (MOSC)

MOSC Banner

Why Does One Order by Work and the Other Does not for TO_CHAR (date,format)

edited Apr 1, 2014 12:17PM in SQL Language (MOSC) 10 commentsAnswered ✓

Hi folks

it is Monday and my brain is not working, I guess

I am trying to figure out why the first sql does not work and the second sql does

I have included the test case , if needed

Thanks for any assistnace

Jim

select

TO_CHAR (col_date,'YYYY-MM-DD HH:MM;SS') col_date

from

test_dates

order by

TO_CHAR (col_date,'YYYY-MM-DD HH:MM;SS');

*

ERROR at line 2:

ORA-01722: invalid number

select

TO_CHAR (col_date,'YYYY-MM-DD HH:MM;SS') col_date

from

test_dates

order by

1;

COL_DATE

-------------------

2014-03-20 08:03;42

2014-03-20 08:03;43

2014-03-21 08:03;42

2014-03-21 08:03;42

Tagged:

Howdy, Stranger!

Log In

To view full details, sign in to My Oracle Support Community.

Register

Don't have a My Oracle Support Community account? Click here to get started.

Category Leaderboard

Top contributors this month

New to My Oracle Support Community? Visit our Welcome Center

MOSC Help Center