DECLARE @NgayDauThang datetime
DECLARE @NgayCuoiThang datetime
SET @NgayDauThang = DATEADD(dd,-(DAY(getdate())-1),getdate())
SELECT @NgayDauThang AS NgayDauThang
SET @NgayCuoiThang = DATEADD(dd,-(DAY(DATEADD(mm,1,getdate()))),DATEADD(mm,1,getdate()))
SELECT @NgayCuoiThang AS NgayCuoiThang
SELECT DATEPART(wk, @NgayDauThang) AS TuanDauCuaThang
SELECT DATEPART(wk, @NgayCuoiThang) AS TuanCuoiCuaThang
--So tuan trong thang
SELECT DATEPART(wk, @NgayCuoiThang) - DATEPART(wk, @NgayDauThang) AS So_Tuan_trong_thang
select dateadd(d, - DATEPART(dw, GETDATE()), GETDATE()) as
FirstDateOfWeek
select dateadd(d, 7-DATEPART(dw, GETDATE()), GETDATE()) as LastDateOfWeek
0 nhận xét:
Speak up your mind
Tell us what you're thinking... !