sql有没有这样的函数.某一天是一个月的第几周
1个回答
展开全部
declare @StartDate varchar(10)
set @StartDate = '2012-05-01'
declare @EndDate varchar(10)
set @StartDate = '2012-10-01'
declare @SWeek int
declare @EWeek int
declare @weeks int
select @SWeek = Datepart(week,@StartDate)
select @EWeek = Datepart(week,@EndDate)
--最终的结果
Select @weeks = @EWeek - @SWeek + 1
--注意,此处两个日期需要为同一年份内,如果跨年,则需要折算年的周数!
set @StartDate = '2012-05-01'
declare @EndDate varchar(10)
set @StartDate = '2012-10-01'
declare @SWeek int
declare @EWeek int
declare @weeks int
select @SWeek = Datepart(week,@StartDate)
select @EWeek = Datepart(week,@EndDate)
--最终的结果
Select @weeks = @EWeek - @SWeek + 1
--注意,此处两个日期需要为同一年份内,如果跨年,则需要折算年的周数!
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询