以文本方式查看主题

-  Foxtable(狐表)  (http://foxtable.net/bbs/index.asp)
--  专家坐堂  (http://foxtable.net/bbs/list.asp?boardid=2)
----  请教 如何取前日期的前一年?  (http://foxtable.net/bbs/dispbbs.asp?boardid=2&id=186784)

--  作者:jswjyjf
--  发布时间:2023/5/29 13:56:00
--  请教 如何取前日期的前一年?
请教 如何取前日期的前一年?
Dim Filter As String
Dim y As Integer = Date.Today.Year
Dim m1 As Integer = Date.Today.Month-12
Dim m As Integer = Date.Today.Month
Dim dt1 As New Date(y, m1, 1)
Dim dt2 As New Date(y, m, Date.DaysInMonth(y, m)) \'获取本月的最后一天
e.Form.Controls("startdate").value=Dt1
e.Form.Controls("enddate").value=Dt2
e.Form.Controls("startdate").value=Dt1
e.Form.Controls("enddate").value=Dt2
Filter ="订单日期 >= \'" & dt1 & "\'  And 订单日期 <= \'" & dt2 & "\'"
\'Filter ="日期 >=#" & dt1 & "#  And 日期 <=#" & dt2 & "#"  & "and 单据状态=\'已审核\'"
With DataTables("订单")
  .LoadFilter = filter
   .Load()
 End With
这样写对吗
[此贴子已经被作者于2023/5/29 13:57:35编辑过]

--  作者:有点蓝
--  发布时间:2023/5/29 13:58:00
--  
http://www.foxtable.com/webhelp/topics/1337.htm

dim d as date = date.today.AddDays(-1).AddYears(-1)