Monday, March 21, 2011

Sql Server

Few days Befor I have tried a lot to get the date in different format SQL

SELECT GETDATE()
ResuleSet:
2007-06-10 7:00:56.107
The required outcome was only 2007/06/10.

SELECT DATEADD(D, 0, DATEDIFF(D, 0, GETDATE()))

using function CONVERT.

SELECT CONVERT(VARCHAR(10),GETDATE(),111)

The reason I use this because it is very convenient as well as provides quick support to convert the date in any format. The table which suggest many format are displayed on MSDN.
Some claims that using CONVERT is slower then using DATE functions but it is extremely negligible.