sql - oracle to_date function not accepting format -


when in oracle 10g:

select to_date(trunc(someinputdate)) table1 to_date(trunc(date_column_timestamp),'mm/dd/yyyy')   >= to_date('03/11/2011' ,'mm/dd/yyyy') 

i get: ora-01843: not valid month if change : 'yyyy/mm/dd', works. 'mm/dd/yyyy' valid format right?

you're getting things mixed bit. to_date converts string date. if date_column_timestamp date, don't need convert date.

select trunc(someinputdate) table1 trunc(date_column_timestamp)   >= to_date('03/11/2011' ,'mm/dd/yyyy') 

the ora-01843 caused implicit conversion of date string. in other words, following:

to_date(trunc(date_column_timestamp),'mm/dd/yyyy') 

is equivalent (assuming default date format dd-mon-yyyy):

to_date(to_char(trunc(date_column_timestamp),'dd-mon-yyyy'),'mm/dd/yyyy') 

so, to_char returns '11-mar-2011', causes to_date fail because date formats not match.

the same problem exists in select clause. don't need to_date around trunc of date column.


Comments

Popular posts from this blog

c# - How to set Z index when using WPF DrawingContext? -

razor - Is this a bug in WebMatrix PageData? -

visual c++ - Using relative values in array sorting ( asm ) -