Robin Hames

Hints, tricks and tips relating to MS SQL Server and .NET
posts - 14 , comments - 45 , trackbacks - 0

Wednesday, November 19, 2008

SQL Server datetime - getting the date part only

I am always forgetting the format for using DATEADD and DATEPART functions to get just part of a SQL Server datetime (e.g. just the date), so I am posting it here so I’ll always know where to find it.
declare @date datetime
set @date = getdate()
select @date, dateadd(day, datediff(day, 0, @date), 0)

Posted On Wednesday, November 19, 2008 3:17 PM | Comments (1) |

Powered by: