//取当前整个星期时间范围
DateTime startDate = DateTime.Today.Date.AddDays(-(int)DateTime.Today.DayOfWeek), // prev sunday 00:00
endDate = startDate.AddDays(7); // next sunday 00:00
//取当前整个月时间范围
int CurrentYear = DateTime.Today.Year;
int CurrentMonth = DateTime.Today.Month;
DateTime startDate = new DateTime(CurrentYear, CurrentMonth, 1);
DateTime endDate = startDate.AddMonths(1).AddMinutes(-1);
//使用
var v = from x in doc.Descendants("Transaction")
where ((DateTime)x.Element("Current_Date")).Date >= startDate
&& ((DateTime)x.Element("Current_Date")).Date < endDate
select new Transaction(x);
|
请发表评论