日期:2014-05-17 浏览次数:20511 次
use tempdb
go
if OBJECT_ID('#') is not null drop table #
create table #(col1 date)
insert into #(col1) values('2013-03-20'),('2013-03-21'),('2013-03-22'),('2013-03-23'),('2013-03-24'),('2013-03-25'),('2013-03-26'),('2013-03-27'),('2013-03-28'),('2013-03-29')
---------------------------------------
declare @today date='2013-03-25'
select top(2) a.col1
from # a
where DATEPART(WEEKDAY,a.col1) not in(1,7)
and a.col1<@today
order by a.col1 desc
/*
col1
-----------------------
2013-03-22
2013-03-21
*/