以文本方式查看主题

-  Foxtable(狐表)  (http://foxtable.net/bbs/index.asp)
--  专家坐堂  (http://foxtable.net/bbs/list.asp?boardid=2)
----  数据 变量 计算  (http://foxtable.net/bbs/dispbbs.asp?boardid=2&id=178689)

--  作者:allwin100
--  发布时间:2022/7/15 23:22:00
--  数据 变量 计算
求教,错在哪,很菜,不好意思。
我试过可以增加一个列,赋值后在表达示列里计算,不过想试着不增加数据列计算

Dim y As Integer = Date.Today.Year
Dim m As Integer = Date.Today.Month
Dim d As Integer = Date.Today.Day
Dim dt1 As New Date(y, m, 1)
Dim dt2 As New Date(y, m, d)
Dim d3 As New Date(y, m, d)
Dim dt3 As Date = d3.AddDays( - 1) \'减去1天
Dim memory1 As Double = DataTables("日").Compute("库存量", "[日期] = #" & dt2 & "#")
Dim memory2 As Double = DataTables("日").Compute("库存量", "[日期] = #" & dt3 & "#")
Dim memory As Double = memory1 - memory2
DataTables("日").ReplaceFor("库存量差值", memory, "[日期] = #" & dt2 & "#")

--  作者:allwin100
--  发布时间:2022/7/16 7:02:00
--  
自己回答吧,写少了一个sum
这个通过,看看可以改简单一些吗
Dim y As Integer = Date.Today.Year
Dim m As Integer = Date.Today.Month
Dim d As Integer = Date.Today.Day
Dim dt1 As New Date(y, m, 1)
Dim dt2 As New Date(y, m, d)
Dim d3 As New Date(y, m, d)
Dim dt3 As Date = d3.AddDays( - 1) \'减去1天
Dim memory1 As Double = DataTables("日").Compute("Sum(库存量)", "[日期] = #" & dt2 & "#")
Dim memory2 As Double = DataTables("日").Compute("Sum(库存量)", "[日期] = #" & dt3 & "#")
Dim memory As Double = memory1 - memory2
DataTables("日").ReplaceFor("库存量差值", memory, "[日期] = #" & dt2 & "#")