alter procedure p_date
@year int=2005, --年份
@week int=33, --第几周
@firstday datetime =null output, --此周的第一天
@endday datetime =null output --此周的最后一天
as
declare @currentWeek int,@currentFirstday datetime
select @currentWeek=datepart(week,getdate()),
@currentFirstday=dateadd(day,1-datepart(weekday,getdate()),getdate())
select @firstday=dateadd(day,7*(@week-@currentWeek),@currentFirstday),
@endday=dateadd(day,7,@firstday)
--select @firstday,@endday
go
[文章转载于csdn论坛: http://bbs.csdn.net/topics/70513840]