Sunday, August 1, 2010

Getting Date from DateTime Type in SQL Server 2005 vs. 2008

In 2008:
Convert(Date,GETDATE())

Select * from myTable where
Convert(Date,ModifiedDate) = Convert(Date,GETDATE())


In 2005:
CONVERT(CHAR(10), GETDATE(), 1)

Select * from myTable where
CONVERT(CHAR(10), ModifiedDate, 1) = CONVERT(CHAR(10), GETDATE(), 1)


Old School:
cast(floor(cast(ModifiedDate as float))as datetime)

No comments: