按日期搜索 [英] Searching By Date

查看:131
本文介绍了按日期搜索的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述


我想在数据库中搜索日期值
我正在尝试通过以下查询来做到这一点:

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.

推荐答案

我怀疑它正在尝试将00:00:00.000与一天中的某个时间进行比较.

您可以使用
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''

,它应该可以工作.


请参阅 THIS [ ^ ]个人解决方案有相同的问题.
See THIS[^] person is having a same problem with solution.


使用yyyy-mm-dd格式
喜欢:
Use yyyy-mm-dd format
Like:
SELECT _id, _amount FROM tbl_list WHERE _Date =''2010-12-31'' 


这篇关于按日期搜索的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆