where datecol>dateadd(day,-7,'2007-6-1') and datename(dw,datecol) not in ('星期六','星期日') 给分吧
这个应该是只有日期 没有星期的数据吧 ?? DATEPART(WEEKDAY,日期) not in () 就行 忘了返回值是啥了 具体 自己查, 这样记忆深
SELECT TOP 5 * FROM Performance p WHERE p.PerformanceDate<'2010-5-1' and datepart(dw,p.PerformanceDate) NOT IN (1,7) ORDER BY p.PerformanceDate
--忘了排序 SELECT TOP 5 * FROM Performance p WHERE p.PerformanceDate<'2010-5-1' and datepart(dw,p.PerformanceDate) NOT IN (1,7) ORDER BY p.PerformanceDate desc
如果变数比较大,可以先用C#获取要查询的日期,再根据这个日期去取数据。
where datecol>dateadd(day,-7,'2007-6-1')
and datename(dw,datecol) not in ('星期六','星期日')
给分吧
DATEPART(WEEKDAY,日期) not in () 就行 忘了返回值是啥了 具体 自己查, 这样记忆深
SELECT TOP 5 * FROM Performance p
WHERE p.PerformanceDate<'2010-5-1' and datepart(dw,p.PerformanceDate) NOT IN (1,7)
ORDER BY p.PerformanceDate
--忘了排序
SELECT TOP 5 * FROM Performance p
WHERE p.PerformanceDate<'2010-5-1' and datepart(dw,p.PerformanceDate) NOT IN (1,7)
ORDER BY p.PerformanceDate desc