This content has been marked as final. Show 8 replies
Keep this concept in Mind
TO_CHAR is to Tell oracle that this column or string is to act as Character String e.g 0123445 this looks like number but it might be some ID Card no etc etc. where Id_card_no = to_char('012345')
TO_date is to Tell oracle that this column or string is to act as Date e.g. 01122010 is looks like number but using to_date u can tell oracle that this is Date and format is DDMMRRRR Where trunc(Date_column) >= trunc(to_date('01122010','DDMMRRRR'))
sometimes using Trunc(date_column) will help to filter all rows because of Time element.
plz mark it helpful / correct if it is.
Because you're comparing apples with bananas.
Let's assume your CREATED column is of DATE datatype (you didn't mention that at all here).
Then your first predicate would be:
And the second one:
where to_char(a.created, 'dd-mon-rr') >= to_char(to_date('26-nov-09','dd-mon-rr'), 'dd-mon-rr')
Always compare DATES to DATES
where a.created >= to_date('26-nov-09', 'dd-mon-rr')
Always compare STRINGS to STRINGS
Never compare STRINGS to DATES etc..
If your CREATED column is not of DATE datatype, then you need to adjust your design, change the table.
I wonder why, in the year 2010, you still use only 2 digits for the year part, instead of 4?
to turn your date datatype into a string.
to turn your string into a date.
Use a format
to tell Oracle how to present the string (to_char) or how to interprete the date (to_date)
You can find all Oracle documentation @ http://tahiti.oracle.com