以文本方式查看主题

-  Foxtable(狐表)  (http://foxtable.net/bbs/index.asp)
--  专家坐堂  (http://foxtable.net/bbs/list.asp?boardid=2)
----  [求助]获取上月的函数有吗  (http://foxtable.net/bbs/dispbbs.asp?boardid=2&id=130336)

--  作者:leeswayne
--  发布时间:2019/1/19 9:27:00
--  [求助]获取上月的函数有吗
老师你好,跟着教程学习,学会了获取筛选本月未付款订单:

Dim y As Integer = Date.Today.Year
Dim m As Integer = Date.Today.Month
Dim dt1 As New Date(y, m, 1)
Dim dt2 As New Date(y, m, Date.DaysInMonth(y, m)) \'获取本月的最后一天
Tables("订单").Filter = " 交期 >= #" & dt1 & "# and 交期 <= #" & dt2 & "# and 货款_已收 = False "

如果想要获取的是上一个月的未付款订单,需要如何获取上一个月的年、月的值?

--  作者:有点蓝
--  发布时间:2019/1/19 9:36:00
--  
Dim y As Integer = Date.Today.Year
Dim m As Integer = Date.Today.Month
Dim dt1 As New Date(y, m, 1)
dt1 = dt1.AddMonths(1)
Tables("订单").Filter = " 交期 >= #" & dt1 & "# and 交期 < #" & dt1.AddMonths(1) & "# and 货款_已收 = False "