Code
--当前日期的周时间段
declare @today datetime
select @today = convert(varchar(10), getdate(), 20)
declare @weekday int
select @weekday = datepart(weekday, @today)
declare @startDate datetime, @endDate datetime
select @startDate = dateadd(dd, 1-@weekday, @today), @endDate = dateadd(dd, 7-@weekday, @today)
SELECT @startDate
SELECT @endDate
--当前日月的时间段
DECLARE @NOW DATETIME
DECLARE @FistDayOfThisMonth DATETIME
DECLARE @LastDayOfThisMonth DATETIME
SET @NOW = convert(varchar(10), getdate(), 20)
SET @FistDayOfThisMonth = @NOW - DAY(@NOW) + 1
SET @LastDayOfThisMonth = DATEADD(MONTH, 1, @NOW - DAY(@NOW) + 1) - 1
SELECT @FistDayOfThisMonth
SELECT @LastDayOfThisMonth
posted @
2008-09-10 13:09
天纯蓝
阅读(
432)
评论()
编辑
收藏
举报