select getdate() as CurrentDateTime;
select DATEADD(d,DATEDIFF(d,0,getdate()),0) as CurrentDate;
select DATEADD(wk,DATEDIFF(wk,0,getdate()),0) as CurrentStartDayOftheWeek;
select DATEADD(mm,DATEDIFF(mm,0,getdate()),0) as CurrentStartDayOftheMonth;
select DATEADD(yy,DATEDIFF(yy,0,getdate()),0) as CurrentStartDayOftheYear;
Result
CurrentDateTime
-----------------------
2011-05-10 11:18:54.857
CurrentDate
-----------------------
2011-05-10 00:00:00.000
CurrentStartDayOftheWeek
------------------------
2011-05-09 00:00:00.000
CurrentStartDayOftheMonth
-------------------------
2011-05-01 00:00:00.000
CurrentStartDayOftheYear
------------------------
2011-01-01 00:00:00.000

0 comments:
Post a Comment