我想要一个查询来获取两个日期之间的数据 [英] I want a query to get data in between two dates
本文介绍了我想要一个查询来获取两个日期之间的数据的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
嗨
我有要求在c#中使用Windowapplication开发离开应用程序,
我需要获取员工数据从两个日期之间休假的数据库(Excel)
示例
从09/09/2016到TO 09/10 / 2016(日期/月/年)
i需要使用c#为windowsapplication获取上述日期之间的数据
我尝试了什么:
Hi
I have a requirement developing Leave application using Windowapplication in c#,
I need to get employee data from database(Excel) who are on leave in between two date
Example
From 09/09/2016 to TO 09/10/2016 (date/month/year)
i need to get data between above dates using c# for windowsapplication
What I have tried:
Hi
I have a requirement developing Leave application using Windowapplication in c#,
I need to get employee data from database(Excel) who are on leave in between two date
Example
From 09/09/2016 to TO 09/10/2016 (date/month/year)
i need to get data between above dates using c# for windowsapplication
推荐答案
通过Odbc照常连接。
然后使用参数化的SQL命令:
Do your connection as usual, via Odbc.
Then use a parameterised SQL command:
string sql = "SELECT Medicine_name, SUM(Medicine_count) AS Medicine_count, To_Date FROM Medicine_count WHERE [To_Date] BETWEEN @SD AND @ED GROUP BY Medicine_name,Medicine_count,To_Date";
OleDbDataAdapter dataadapter = new OleDbDataAdapter(sql, con);
dataadapter.SelectCommand.Parameters.AddWithValue("@SD", startDate);
dataadapter.SelectCommand.Parameters.AddWithValue("@ED", endDate);
并以通常的方式使用数据适配器。
And use teh data adapter in the usual way.
这篇关于我想要一个查询来获取两个日期之间的数据的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文