如题 有一个datetimepicker 控件和按钮,数据库名:grade 要查询的数据是:操作信息
怎么用selcet语句查询到datetimepicker当前月份的全部操作信息数据呢!
vb.net +access数据库 一个月内的某段数据查询
答案:1 悬赏:60
解决时间 2021-03-01 21:36
- 提问者网友:浪荡羁士
- 2021-03-01 14:09
最佳答案
- 二级知识专家网友:蜜罐小熊
- 2021-03-01 15:23
乍看难点是本月日期提取,下面是代码
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Dim date_start As Date = DateTimePicker1.Value.Year & "-" & DateTimePicker1.Value.Month '本月的开始日期(包含)
Dim date_end As Date = DateTimePicker1.Value.Year & "-" & DateTimePicker1.Value.Month
date_end = date_end.AddMonths(1) '本月的终止日期(不包含)
Dim str As String = "selcet * from 数据表 where 日期>=#" & date_start & "# and 日期<#" & date_end & "#" '这里是查询表达式
End Sub
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Dim date_start As Date = DateTimePicker1.Value.Year & "-" & DateTimePicker1.Value.Month '本月的开始日期(包含)
Dim date_end As Date = DateTimePicker1.Value.Year & "-" & DateTimePicker1.Value.Month
date_end = date_end.AddMonths(1) '本月的终止日期(不包含)
Dim str As String = "selcet * from 数据表 where 日期>=#" & date_start & "# and 日期<#" & date_end & "#" '这里是查询表达式
End Sub
我要举报
如以上问答内容为低俗、色情、不良、暴力、侵权、涉及违法等信息,可以点下面链接进行举报!
大家都在看
推荐资讯
• 手机登qq时,显示手机磁盘不足,清理后重新登 |
• 刺客的套装怎么选啊? |