Search this blog

Friday, October 15, 2010

Extract Only Date from Date time field

Today, one of my friend asked me, how to extract only Date from Datetime field.

The following SQL Script helps to Extract only Date from DateTime field, it will ignore the time and display as "00:00:00.000".

SELECT DATEADD(dd, 0, DATEDIFF(dd, 0, GETDATE()))
Here I used the GetDate() function. In the Same way, we can use any datefield column.
There are other ways also there, but datatype and Dateformat is different

Select convert(varchar, getdate(), 101)


Select convert(varchar, getdate(), 102)

Select convert(varchar, getdate(), 103)

Select convert(varchar, getdate(), 104)

Select convert(varchar, getdate(), 105)

Select convert(varchar, getdate(), 106)

Select convert(varchar, getdate(), 107)

No comments:

Post a Comment