以文本方式查看主题 - Foxtable(狐表) (http://foxtable.net/bbs/index.asp) -- 专家坐堂 (http://foxtable.net/bbs/list.asp?boardid=2) ---- 日期时间查询代码问题 (http://foxtable.net/bbs/dispbbs.asp?boardid=2&id=106329) |
-- 作者:benwong2013 -- 发布时间:2017/9/6 18:49:00 -- 日期时间查询代码问题 某一列的格式为datetime,现在在窗体中DateTimePicker 输入开始及结束日期,希望将此日期段所有涉及的数据列出,请问以下这个代码应该如何修改 With e.Form.Controls("DateTimePicker5") If .Value IsNot Nothing Then If Filter >"" Then Filter = Filter & " And " End If Filter = Filter & "提交时间 >= \'" & .Value.AddDays(-1) & "\'" End If End With With e.Form.Controls("DateTimePicker6") If .Value IsNot Nothing Then If Filter >"" Then Filter = Filter & " And " End If Filter = Filter & "提交时间 <= \'" & .Value.AddDays(1) & "\'" End If End With |
-- 作者:benwong2013 -- 发布时间:2017/9/6 18:58:00 -- 将代码改成这样可以实现,请问还有其它方式吗? With e.Form.Controls("DateTimePicker5") If .Value IsNot Nothing Then If Filter >"" Then Filter = Filter & " And " End If Filter = Filter & "提交时间 >= \'" & .Value & " 00:00 \'" End If End With With e.Form.Controls("DateTimePicker6") If .Value IsNot Nothing Then If Filter >"" Then Filter = Filter & " And " End If Filter = Filter & "提交时间 <= \'" & .Value & " 23:59 \'" End If End With |
-- 作者:有点甜 -- 发布时间:2017/9/6 19:29:00 -- With e.Form.Controls("DateTimePicker5") If .Value IsNot Nothing Then If Filter >"" Then Filter = Filter & " And " End If Filter = Filter & "提交时间 >= \'" & .Value & "\'" End If End With With e.Form.Controls("DateTimePicker6") If .Value IsNot Nothing Then If Filter >"" Then Filter = Filter & " And " End If Filter = Filter & "提交时间 < \'" & .Value.AddDays(1) & "\'" End If End With |