从表中检索给定日期条件的数据

编程入门 行业动态 更新时间:2024-10-25 05:12:17
本文介绍了从表中检索给定日期条件的数据的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

在我的表格中,我有一个日期时间类型的字段.我想从表中选择少于给定日期的值.但是在表中,因为它包含了我提供诸如创建日期< =''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;

更多推荐

从表中检索给定日期条件的数据

本文发布于:2023-10-30 19:03:15,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1543723.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:条件   日期   数据

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!