sql 日期问题从周转换到日期

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]

posted @ 2014-06-09 11:02  愤怒的小鹏  阅读(655)  评论(0编辑  收藏  举报