![Share on Facebook Facebook](https://www.sqlserver.info/wp-content/plugins/social-media-feather/synved-social/image/social/regular/48x48/facebook.png)
![Share on Twitter twitter](https://www.sqlserver.info/wp-content/plugins/social-media-feather/synved-social/image/social/regular/48x48/twitter.png)
![Share on Reddit reddit](https://www.sqlserver.info/wp-content/plugins/social-media-feather/synved-social/image/social/regular/48x48/reddit.png)
![Pin it with Pinterest pinterest](https://www.sqlserver.info/wp-content/plugins/social-media-feather/synved-social/image/social/regular/48x48/pinterest.png)
![Share on Linkedin linkedin](https://www.sqlserver.info/wp-content/plugins/social-media-feather/synved-social/image/social/regular/48x48/linkedin.png)
![Share by email mail](https://www.sqlserver.info/wp-content/plugins/social-media-feather/synved-social/image/social/regular/48x48/mail.png)
A common function that people need to do when dealing with datetimes is extracting the date from the datetime. Oracle has a built-in function to do this called TRUNC. SQL Server does not have this (yet). However… you can accomplish this very easily. Here are a few ways to perform a truncate date function in SQL Server.
-- Assign date to variable DECLARE @DateToTruncate DATETIME = '2014-08-01 14:12:34' -- Get the date using casts SELECT CAST(CAST(@DateToTruncate AS DATE) AS DATETIME) -- Get the date using convert SELECT CAST(CONVERT(VARCHAR(10), @DateToTruncate, 101) AS DATETIME)