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

时间:2014-06-09 16:57:30   收藏:0   阅读:225

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]

sql 日期问题从周转换到日期,布布扣,bubuko.com

评论(0
© 2014 mamicode.com 版权所有 京ICP备13008772号-2  联系我们:gaon5@hotmail.com
迷上了代码!