通过下面的代码,我可以从datatable(dt1)中根据当前周和当前年份选择行.thanks (“Objectif”)值。
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")
)发布于 2015-02-03 17:42:22
您可以将<和>与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视为独占的,这通常(但并不总是)是一个好主意。
https://stackoverflow.com/questions/28305258
复制相似问题