Click here to Skip to main content
15,891,846 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
Hi,
I want to search in the database for date value
and I'm trying to do this with these queries:

SELECT _id, _amount FROM tbl_list WHERE _Date ='12/31/2010'

and
SELECT _id, _amount FROM tbl_list WHERE _Date =Cast('12/31/2010' as DateTime)


But this doesn't return any value.
If someone has an idea to overcome this problem please suggest.

Thanks in advance.
Posted
Updated 31-Dec-10 5:37am
v4

I would suspect it is trying to compare 00:00:00.000 to a time of day.

You can use
SELECT _id, _amount FROM tbl_list WHERE CONVERT(VARCHAR, _Date, 101) ='12/31/2010'
and it should work.
 
Share this answer
 
See THIS[^] person is having a same problem with solution.
 
Share this answer
 
Use yyyy-mm-dd format
Like:
SELECT _id, _amount FROM tbl_list WHERE _Date ='2010-12-31' 
 
Share this answer
 
Comments
NBajaj 2-Jan-11 23:04pm    
it's not working

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900