设为首页 加入收藏

TOP

机房收费系统之―怎样查询两个日期之间的数据
2015-07-24 11:35:31 来源: 作者: 【 】 浏览:4
Tags:机房 收费系统 怎样 查询 两个日期 之间 数据

日历控件刚刚学会怎么弄,但是要查询这两个语句之间的数据的语法我可是较劲脑汁啊,在网上查,自己试,可是每次不是语法错误就是连接不上数据库,我感觉这个方法就在我的眼前,我就是弄不出来,煞费苦心啊。下面是查询两个日历控件之间的代码,大家可以看看。

Private Sub Command1_Click()
    date1 = DTPicker1.Value‘这是日历控件
    date2 = DTPicker2.Value
    '比较两个日期的大小
    If DateDiff("n", CDate(date1), CDate(date2)) < 0 Then
        MsgBox "起始日期与结束日期有冲突,请重新选择日期", , "提示"
        Exit Sub
    End If
    txtSQL = "select * from Recharge_Info where date >='" & date1 & "' and date <='" & date2 & "'"
    Set mrc = ExecuteSQL(txtSQL, Msgtext)
    If mrc.EOF = True Then
        MsgBox "没有信息"
        Exit Sub
    End If
    With MSFlexGrid1
   
        Do While mrc.EOF = False
            .CellAlignment = 4
            .Rows = .Rows + 1
            .TextMatrix(.Rows - 2, 0) = mrc!cardno
            .TextMatrix(.Rows - 2, 1) = mrc!addmoney
            .TextMatrix(.Rows - 2, 2) = mrc!Date
            .TextMatrix(.Rows - 2, 3) = mrc!Time
            .TextMatrix(.Rows - 2, 4) = mrc!userID
            .TextMatrix(.Rows - 2, 5) = mrc!Status
            mrc.MoveNext
            If mrc.EOF = True Then
                .Rows = .Rows - 1
            End If
        Loop
    End With
    mrc.Close
End sub

写了一大堆,其实最有用的是这句话
txtSQL = "select * from Recharge_Info where date >='" & date1 & "' and date <='" & date2 & "'"
此方法不仅可以比较日期,以此类推,基本上带数字的都能比较吧!
】【打印繁体】【投稿】【收藏】 【推荐】【举报】【评论】 【关闭】 【返回顶部
分享到: 
上一篇学生表sid,sname,成绩表cid,cname.. 下一篇Redis集群_1.redis安装

评论

帐  号: 密码: (新用户注册)
验 证 码:
表  情:
内  容:

·Shell 中各种括号的 (2025-12-24 19:50:39)
·Shell 变量 - 菜鸟教 (2025-12-24 19:50:37)
·Linux source 命令 - (2025-12-24 19:50:34)
·switch520最新的地址 (2025-12-24 19:19:41)
·微信聊天功能使用了 (2025-12-24 19:19:39)