以文本方式查看主题

-  Foxtable(狐表)  (http://foxtable.net/bbs/index.asp)
--  专家坐堂  (http://foxtable.net/bbs/list.asp?boardid=2)
----  [求助]筛选的问题,求助。  (http://foxtable.net/bbs/dispbbs.asp?boardid=2&id=77072)

--  作者:why305
--  发布时间:2015/11/10 16:25:00
--  [求助]筛选的问题,求助。
想做两个按钮,一个按钮是筛选出本周计划内容,一个是筛选出下周计划内容。
根据列里的内容,本周就是2015-11-09 00:00:00至2015-11-15 23:59:59。
下周依次类推。
老师代码怎么写啊。谢谢

--  作者:大红袍
--  发布时间:2015/11/10 16:27:00
--  

 Dim y As Integer = Date.Today.Year
Dim w As Integer = Date.Today.DayOfWeek \'算出今天是星期几
Dim dt1 As Date = Date.Today.AddDays(-w+1) \'获取本周的第一天
Dim dt2 As Date = dt1.AddDays(7)
Dim Filter As String
Filter = "日期 >= #" & dt1 & "# And 日期 < #" & dt2 & "#"
msgbox(filter)
Tables("订单").Filter = Filter

 

---------------

 

Dim y As Integer = Date.Today.Year
Dim w As Integer = Date.Today.DayOfWeek \'算出今天是星期几
Dim dt1 As Date = Date.Today.AddDays(-w+1).addDays(7) \'获取本周的第一天
Dim dt2 As Date = dt1.AddDays(7)
Dim Filter As String
Filter = "日期 >= #" & dt1 & "# And 日期 < #" & dt2 & "#"
msgbox(filter)
Tables("订单").Filter = Filter


--  作者:why305
--  发布时间:2015/11/10 16:49:00
--  
以下是引用大红袍在2015/11/10 16:27:00的发言:

 Dim y As Integer = Date.Today.Year
Dim w As Integer = Date.Today.DayOfWeek \'算出今天是星期几
Dim dt1 As Date = Date.Today.AddDays(-w+1) \'获取本周的第一天
Dim dt2 As Date = dt1.AddDays(7)
Dim Filter As String
Filter = "日期 >= #" & dt1 & "# And 日期 < #" & dt2 & "#"
msgbox(filter)
Tables("订单").Filter = Filter

 

成功啦,谢谢老师,我不会写代码,0基础啊,谢谢老师指点。

---------------

 

Dim y As Integer = Date.Today.Year
Dim w As Integer = Date.Today.DayOfWeek \'算出今天是星期几
Dim dt1 As Date = Date.Today.AddDays(-w+1).addDays(7) \'获取本周的第一天
Dim dt2 As Date = dt1.AddDays(7)
Dim Filter As String
Filter = "日期 >= #" & dt1 & "# And 日期 < #" & dt2 & "#"
msgbox(filter)
Tables("订单").Filter = Filter