如何使用“日期大于"选择一天的数据?询问 [英] how to select data of one day using "date greate than" query

查看:61
本文介绍了如何使用“日期大于"选择一天的数据?询问的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

< b>我正在使用列表视图来查看两个选定日期之间的数据,我有两种方法:

1.从mytable中选择*,其中mydate在""+ fromdate +"和""+ todate +"''之间;


2.从mytable中选择*,其中mydate& gt ==""+ fromdate +"''和mydate& lt ==" + todate +''";

但是问题是如果我选择与fromdate和todate相同的日期,其中表中存在未显示的记录!
任何帮助都请以简单的方式
谢谢
</b>

<b>Hi I am using a list view to view the data between two selected dates i have two ways:

1. "select * from mytable where mydate between ''" + fromdate + "'' and ''" + todate + "''";


2. "select * from mytable where mydate&gt;= ''" + fromdate + "'' and mydate&lt;= ''" + todate + "''";

but the problem is if i select the same date as fromdate and todate in which there exist records in table that does not show!
Any help please in simple way
thanks
</b>

推荐答案

您需要正确地转换日期并丢失时间部分.

尝试fromdate.ToString("yyyy-MM-dd")todate.ToString("yyyy-MM-dd")

祝你好运!
You need to convert the date correctly and lose the time part.

Try fromdate.ToString("yyyy-MM-dd") and todate.ToString("yyyy-MM-dd")

good luck!


这篇关于如何使用“日期大于"选择一天的数据?询问的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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