[2005] Working with Oracle Dates
Hi
Am trying to write a dynamic sql query that fetches data from oracle 10g database. My Where criteria is giving me real problems but i guess it has to do with the oracle data format. The data column is a TIMESTAMP data type storing values like 25-JAN-09 07.06.01.000000000 AM. Am trying to get rows having the columns matching a specific date( ignoring the time values), my where looks like this
WHERE to_date(COMPLY_RUN_DASHBOARD_DATE,'DD-MON-RR')='" & Now.Date & "'"
i get the following error :
CheckError
ORA-01830: date format picture ends before converting entire input string
plz, any clue?
Re: [2005] Working with Oracle Dates
Don't ever build SQL statements using string concatenation. This is just one example of the problems it causes. If you always use parameters then you'll never encounter this issue or a host of others. Follow the ADO.NET Examples link for several examples of inserting values into SQL code using parameters.
Just note that that code is for SQL Server, although Oracle code will be almost identical. Where SQL Server prefixes parameters with "@" though, I believe Oracle uses ":".