I am trying to input a date value from the user and then using that value in the query.
select * from TB_MNP_GTY_TRANS_STEPS where CREATE_DATETIME>=&startdate
Now when i run the sql statement in Toad and input 8/1/2012 as date data type i am getting
ORA-00932: inconsistent datatypes: expected DATE got NUMBER
Can someone suggest where i am wrong.Note that CREATE_DATETIME is of Date Type.
You should really specify what date format you are using in your parameter:
Read about date formats here
Currently your session is expecting the date to be in its default NLS_DATE default fomat and obviously the format of the date you’re entering is different.
Explicitly specifying date formats prevents this issue from occurring.
Hope it helps…
EDIT:
If you want to pass in the 8th January 2012 then you could specify your variable value as:
And your select would be:
Depending upon your environment you might need to wrap the variable in single quotes (for TOAD you definiely will) i.e.
The error you are getting is caused by the format of the date string you are entering not matching EXACTLY the format you are specifying (see the leading “
0” before the8and1in the day and month!)