Skip to main content

Comparing or fetching only date parts (without time) from datetime in SQL Server

The function Cast(Floor(Cast(GetDate() As Float)) As DateTime) returns a datetime datatype with the time portion removed and could be used as so.


Select * Table1 Where  Cast(Floor(Cast(Column_DateTime As Float)) As DateTime) = '14-AUG-2008'
       or
DECLARE @p_date DATETIME
SET @p_date = Cast('14 AUG 2008' as DateTime)
SELECT * FROM table1 WHERE Cast(Floor(Cast(column_datetime As Float)) As DateTime) = @p_date