I have a date column whose type is DATE and values are of the form 23-AUG-12, 09-FEB-12. Now i am trying to run a query but i am getting error that
ORA-01843: not a valid month
01843. 00000 - "not a valid month"
*Cause:
*Action:
Here is the query. Actually i want to get the current date on the right side of first_appr_dt = current date
select LOSA_APP.app_ref_no AS "App.Ref.No." from losa_app LOSA_APP where
LOSA_APP.app_status='A' and first_appr_dt =
(SELECT TO_CHAR(SYSDATE, 'MM-DD-YYYY') from dual);
What i am doing wrong ? Please help .
Thanks
If the column
first_appr_dtis really aDATEcolumn, then there’s no need to to compare the dates as string. In fact, it’s probably the source of the problem.Furthermore, there’s no need select from DUAL for this simple expression.
You rather want:
Note, that the query uses
TRUNCto remove the time from the date as your table probably contains dates with the time set to 00:00:00. If not, then you should try the following condition:If you really want to compare the dates as strings, then you would need to use
TO_CHARfor both sides of the comparison: