查询日期范围时查询不返回记录 [英] Query not returning record when searching range of dates
本文介绍了查询日期范围时查询不返回记录的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
在我的SQl数据库中,我有一个WHERE语句根据两个日期搜索记录。
使用下面的代码,查询不会返回如果SearchDate = FromDate则记录。
在我的记录中,数据库中的示例日期范围是:
Hi,
in my SQl database, I have a WHERE statement to search a record based on two dates.
using the code below, Query will not return a record if SearchDate=FromDate.
Amongst my records, an example date range in database is:
展开 | 选择 | 换行 | 行号
推荐答案
从您使用日期时间格式比较日期的代码中。
所以
PHD.FromDate< = Convert(DateTime,''/ 04/2014'',103)
成为
''2014-04-10 17:32:55.000''< =''2014-04-10 00:00: 00.000''
您可能想要将代码更改为
From the code you are comparing the dates in Datetime format.
So
PHD.FromDate <= Convert(DateTime, ''10/04/2014'' ,103)
becomes
''2014-04-10 17:32:55.000'' <= ''2014-04-10 00:00:00.000''
You may want to change your code to
展开 | 选择 | 换行 | 行号
感谢您的回复。
您的代码对我不起作用。但是,我把它更改为
Thanks for the reply.
Your code not work for me. However, I changed it to
展开 | 选择 | Wrap | < span class =codeLinkonclick =LineNumbers(this);>行号
你有''< =''和''> =' '错误...
you have the ''<='' and ''>='' wrong...
展开 | 选择 | Wrap | 行号
这篇关于查询日期范围时查询不返回记录的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文