SQL Remove time from Date/Time Stamp

There are 3 commonly used methods to remove the time from a SQL Server date / time stamp.  Here is an example of each method and benefits of one over another.

1. Using DateDiff method

The DateDiff method is the preferred method for removing the time from a Date/Time Stamp.

DateAdd(dd,DateDiff(d,0,GetDate()),0)
2. Using Float and Floor method

The float method is similar to the DateDiff method but uses internal storage for the calculation.

CAST(FLOOR(CAST(GetDate() AS FLOAT)) AS DateTime)
3. Using Char method

The char method is the least desirable method because it is subject to language and date format issues.

CAST(CONVERT(char(10),GetDate(),101) AS DateTime)

This entry was written by Administrator, posted on Tuesday, December 29, 2009 Bookmark the permalink. Follow any comments here with the RSS feed for this post. You can post a comment.

1 comment for “SQL Remove time from Date/Time Stamp”

  1. Gravatar of Kundan guptaKundan gupta
    Posted Friday, December 23, 2011 at 10:17:40 AM

    Check this helpful link too...
    http://mindstick.com/Articles/b08c8553-60a2-4f35-a58f-60c538c7d136/?%E2%80%98SELECT%E2%80%99%20Command%20with%20Date%20Method
    Its having nice post with wonderful explanation on datetime methods in sql server.

Post a comment