如何使用日期时间选择器从数据库访问特定月份或特定一周的记录 [英] How to access a particular month or a particular week's records from database by using a datetimepicker
本文介绍了如何使用日期时间选择器从数据库访问特定月份或特定一周的记录的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我在使用datetimepicker访问一周或一个月的数据时遇到问题.请告诉我该查询仅访问某些特定数据,即特定星期或特定月份的记录.
I have problem in accessing data for a week or month using a datetimepicker. please tell me the query to access only some specific data i.e. particular week or particular month''s record''s.
推荐答案
尝试:
SELECT * FROM myTable WHERE date>=''2011-04-01" AND date <''2011-05-01''
我假设您有两个datetimepicker
在您的搜索按钮上尝试此操作单击事件
I assume you have two datetimepicker
Try this on you Search Button Click Event
Dim sd As New SqlDataAdapter("Select * From table where DateOfEntry_From=''" + dtp.Text.ToString() + "'' and DateOfEntry_To=''" + dtp2.Text.ToString() + "''", myCon.con())
Dim dt As New DataTable
sd.Fill(dt)
If dt.Rows.Count > 0 Then
dgV.DataSource = dt
Else
dgV.DataSource = Nothing
MessageBox.Show("No data found ")
End If
根据您的要求实施
Implement as per your requirement
这篇关于如何使用日期时间选择器从数据库访问特定月份或特定一周的记录的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文