var query = records.Where(record =>
(record.StartTime >= startTime && record.EndTime <= endTime) ||
(startTime >= record.StartTime && endTime <= record.EndTime)
);
where(a=> a.time>=Start && a.time<=End)
数据表中的时间字段也是两个,start和end
感谢回答
dbContext.Set<T>.Where(x => EF.Functions.DateDiffDay(x.CreateTime, startTime) <= 0 && EF.Functions.DateDiffDay(x.CreateTime, endTime) >= 0)
--sqlserver
select * from Tabel1 x
where DateDiff( DAY, x.CreateTime, @startTime) <= 0 and DateDiff( DAY, x.CreateTime, @endTime) >=0;
--mysql
select * from Tabel1 x
where TIMESTAMPDIFF( DAY, x.CreateTime, @startTime) <= 0 and TIMESTAMPDIFF( DAY, x.CreateTime, @endTime) >=0;
EF.Functions.DateDiffYear()
年
EF.Functions.DateDiffMonth()
月
EF.Functions.DateDiffDay()
天
EF.Functions.DateDiffHour()
小时
EF.Functions.DateDiffMinute()
分钟
EF.Functions.DateDiffSecond()
秒
EF.Functions.DateDiffMicrosecond()
毫秒
大佬,我是两个两段时间范围内取交集哦。 数据表中寸的有两个字段,一个开始时间一个结束时间的。前台再传一个时间范围过来筛选的
感谢回答