Saturday, October 3, 2009

Date datatype in SQL Server 2008

Most developers that I have talked to have always been intrigued as why we did not have a datatype which stores just a simple date (Year-Month-Day). Microsoft has finally introduced this in SQL Server 2008.
No more using Datepart or Year, Month and Day functions to get just the date part.

DECLARE @d DATE
SET @d = GETDATE()
SELECT @d

returns
2009-10-02