大佬教程收集整理的这篇文章主要介绍了机房收费系统之—怎样查询两个日期之间的数据,大佬教程大佬觉得挺不错的,现在分享给大家,也给大家做个参考。
日历控件刚刚学会怎么弄,但是要查询这两个语句之间的数据的语法我可是较劲脑汁啊,在网上查,自己试,可是每次不是语法错误就是连接不上数据库,我感觉这个方法就在我的眼前,我就是弄不出来,煞费苦心啊。下面是查询两个日历控件之间的代码,大家可以看看。
<pre name="code" class="vb"><span style="font-size:18px;">Private Sub Command1_Click() date1 = DTPicker1.Value date2 = DTPicker2.Value '比较两个日期的大小 if DateDiff("n",CDate(date1),CDate(date2)) < 0 Then MsgBox "起始日期与结束日期有冲突,请重新选择日期","提示" Exit Sub End If Dim i,iCols As Integer '让所有列的文字都居中显示 iCols = MSFlexGrid1.Cols For i = 0 To iCols - 1 MSFlexGrid1.ColAlignment(i) = flexAlignCenterCenter Next txtSQL = "SELEct * from Recharge_Info where date between '" & date1 & "'" & " and '" & date2 & "'" Set mrc = ExecuteSQL(txtSQL,Msgtext) If mrc.EOF = True Then MsgBox "没有信息" Exit Sub End If With MSFlexGrid1 Do While mrc.EOF = false .Rows = .Rows + 1 .TextMatrix(.Rows - 1,0) = mrc!cardno .TextMatrix(.Rows - 1,1) = mrc!addmoney .TextMatrix(.Rows - 1,2) = mrc!Date .TextMatrix(.Rows - 1,3) = mrc!Time .TextMatrix(.Rows - 1,4) = mrc!userID .TextMatrix(.Rows - 1,5) = mrc!Status mrc.MoveNext Loop End With mrc.Close End Sub </span>
<pre name="code" class="vb">txtSQL = "SELEct * from Recharge_Info where date between'" & Format$(date1,"yyyy - mm - dd") & "'" & " and'" & Format$(date2,"yyyy-mm-dd") & "'" txtSQL = "SELEct * from Recharge_Info where date >='" & date1 & "' and date <='" & date2 & "'"上面的两句话写那句也行,看我们的不同需要了。
以上是大佬教程为你收集整理的机房收费系统之—怎样查询两个日期之间的数据全部内容,希望文章能够帮你解决机房收费系统之—怎样查询两个日期之间的数据所遇到的程序开发问题。
如果觉得大佬教程网站内容还不错,欢迎将大佬教程推荐给程序员好友。
本图文内容来源于网友网络收集整理提供,作为学习参考使用,版权属于原作者。
如您有任何意见或建议可联系处理。小编QQ:384754419,请注明来意。