Thursday, June 11, 2009
@StartDate为输入日期 @i为天数
--输入日期上个月第一天:select convert(varchar(10),dateadd(mm,-1,DATEADD(mm, DATEDIFF(mm,0,@StartDate),0)),120)
--输入日期上个月最后一天 :select dateadd(ms,-3,DATEADD(mm, DATEDIFF(mm,0,@StartDate), 0))
--把输入日期添加上时间:select DATEADD(day,DATEDIFF(day,0,@StartDate),0)
--输入日期相隔几天的日期:select DATEADD(day,@i,DATEADD(day,DATEDIFF(day,0,@StartDate),0))