tyruss8
asked on
PL SQL Developer
Hello,
I'm trying to query a table for services in 2015. Can someone tell me what is wrong with my code?
Table: MyTable
Column: ServicDate; Datatype Varchar2(8); Example values are 20140404; 20150101, etc..
My code that is not working.
Select *
From MyTable x
where x.ServiceDate >= to_date('01/01/2015','mm/d d/yyyy')
AND x.ServiceDate <= to_date('12/31/2015','mm/d d/yyyy')
;
Thanks
Tyruss8
I'm trying to query a table for services in 2015. Can someone tell me what is wrong with my code?
Table: MyTable
Column: ServicDate; Datatype Varchar2(8); Example values are 20140404; 20150101, etc..
My code that is not working.
Select *
From MyTable x
where x.ServiceDate >= to_date('01/01/2015','mm/d
AND x.ServiceDate <= to_date('12/31/2015','mm/d
;
Thanks
Tyruss8
ASKER
Hi,
Thanks for your quick response but I'm still getting an error of "a non-numeric character was found where a numeric was expected"
Thanks
Thanks for your quick response but I'm still getting an error of "a non-numeric character was found where a numeric was expected"
Thanks
>>to_date('01/01/2015','YY YYMMDD')
That will NEVER work. The date string must match the format mask.
>>Can someone tell me what is wrong with my code?
From an Oracle syntax side: Nothing is wrong. That is correct syntax.
If you connect using sqlplus or SQL Developer, you should be able to run that as-is.
>>I'm trying to query a table for services in 2015.
What does this mean? Are you using SQL Server and a pass-through query or something else?
That will NEVER work. The date string must match the format mask.
>>Can someone tell me what is wrong with my code?
From an Oracle syntax side: Nothing is wrong. That is correct syntax.
If you connect using sqlplus or SQL Developer, you should be able to run that as-is.
>>I'm trying to query a table for services in 2015.
What does this mean? Are you using SQL Server and a pass-through query or something else?
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Thanks for everybody's solutions I appreciate it. But for my issue this was solved by 'johnsone'!
I tested it a few times with other dates in 'yyyymmdd' format and it's giving me the expected data.
Thank you!
I tested it a few times with other dates in 'yyyymmdd' format and it's giving me the expected data.
Thank you!
ASKER
Thank you!
Yes, I missed the varchar2 data type and data examples.
Please try this -
Open in new window
Hope it helps!