从表中检索给定日期条件的数据 [英] Retrieve data from table for given date condition

查看:81
本文介绍了从表中检索给定日期条件的数据的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在我的表格中,我有一个日期时间类型的字段.我想从表中选择少于给定日期的值.但是在表中,因为它包含了我提供诸如创建日期< =''03/05/2011''之类的日期值的时间,它没有给出``03/05/2011''的值.

In my table I have a field with datetime type. I want to select values from the table that less than a given date. But in table as it contains with the time when I give the date value like createddate <= ''03/05/2011'' it doesnt give the ''03/05/2011'' value.

推荐答案

确保datetime字段中没有时间成分.我曾经遇到过类似的情况,花了几个小时后发现我的数据有一个时间字段,并且没有在查询中选择结果.
Make sure there is no time component in the datetime field. I once faced a similar situation and after spending a few hours noticed that my data had a time field and a result was not being selected in my query.


如果您从aspx传递数据您可以尝试的页面


if you are passing your data from aspx page you can try


 DateTime.MaxValue.ToLongTimeString() property to your datatime variable 


and in Database you can query like 

select * from Table where   CreatedDate < GivenDate    


尝试使用mm/dd/yyyy格式& gt;
try with mm/dd/yyyy format&gt;


这篇关于从表中检索给定日期条件的数据的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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