使用下面的代码我可以根据数据表(dt1)中的当前周和当前年份选择行.field(“Objectif)值。如何通过将一系列日期作为条件来做同样的事情?示例从2014年9月1日到2015年9月1日。谢谢
dim ThisWeekTotal = (
From Row In dt1.AsEnumerable
Where MyCalendar.GetWeekOfYear(Row.Field(Of DateTime)("date"),
CalendarWeekRule.FirstFourDayWeek,
DayOfWeek.Sunday) = Currentweek And MyCalendar.GetYear(Row.Field(Of DateTime)("date")) = Currentyear
Select Row.Field(Of Double)("objectif")
)
答案 0 :(得分:0)
您可以将<
和>
与DateTime
值一起使用,这样您就可以执行以下操作:
Dim lowerBound As DateTime = ...
Dim upperBound As DateTime = ...
... in the query ...
Where lowerBound <= Row.Field(Of DateTime)("date") AndAlso
Row.Field(Of DateTime)("date") < upperBound
将lowerBound
视为包容性,将upperBound
视为独占,通常(但并非总是)是一个好主意。