Geeks With Blogs
Robin Hames Hints, tricks and tips relating to MS SQL Server and .NET
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 SQL Server | Back to top


Comments on this post: SQL Server datetime - getting the date part only

# re: SQL Server datetime - getting the date part only
Requesting Gravatar...
Remember that in SQL Server 2008, you can use CAST with the new Date type to get the same results.
Left by Christopher Reed on Nov 19, 2008 6:01 PM

Your comment:
 (will show your gravatar)


Copyright © Rhames | Powered by: GeeksWithBlogs.net | Join free