NOTE: This answer returns the original DATETIME or DATETIME2 type. For an expression that returns a true DATE type (SQL Server 2008 and later), see BenR's answer below.

SELECT DATEADD(dd, 0, DATEDIFF(dd, 0, @your_date))

for example

SELECT DATEADD(dd, 0, DATEDIFF(dd, 0, GETDATE()))

gives me

2008-09-22 00:00:00.000

Pros:

  • No varchar<->datetime conversions required
  • No need to think about locale
Answer from aku on Stack Overflow
Discussions

SELECT Datetime values using where clause
I have a dataset similer to below code. CREATE TABLE TEST.[dbo].[dt] ( [TRAN DATE] datetime ) INSERT INTO TEST.[dbo].[dt] ([TRAN DATE]) VALUES ('2017-01-01 08:24:03.000'), ('2017-01-03 10:24:03.000'), ('2017-02-10 09:50:03.000'), ('2017-03-05 12:24:03.000'), ('2017-04-17 20:24:03.000') -- Select ... More on forums.sqlteam.com
🌐 forums.sqlteam.com
0
0
April 24, 2017
How to query DATETIME field using only date in Microsoft SQL Server? - Stack Overflow
I have a table TEST with a DATETIME field, like this: ID NAME DATE 1 TESTING 2014-03-19 20:05:20.000 What I need a query returning this row and every row with date 03/19/2014, no matter what the t... More on stackoverflow.com
🌐 stackoverflow.com
sql server - Extract Date Portion Only From DateTime Field - Database Administrators Stack Exchange
In SQL Server 2008 I use this to take out only the date piece Cast(field as date). For example, if I use the below garbage DDL Create Table #Bbb ( id int ,datetime1 datetime ) In... More on dba.stackexchange.com
🌐 dba.stackexchange.com
March 9, 2016
sql - Using a date value in where clause on a datetime data type - Stack Overflow
Is there anything I should be cautious of when using a date in the where statement if the field I am filtering on is a datetime? Does WHERE Date = '20190604' actually get interpreted as '2019-06-04... More on stackoverflow.com
🌐 stackoverflow.com
Top answer
1 of 7
117
WHERE datetime_column >= '20081220 00:00:00.000'
  AND datetime_column < '20081221 00:00:00.000'
2 of 7
29

First of all, I'd recommend using the ISO-8601 standard format for date/time - it works regardless of the language and regional settings on your SQL Server. ISO-8601 is the YYYYMMDD format - no spaces, no dashes - just the data:

select * from tblErrorLog
where errorDate = '20081220'

Second of all, you need to be aware that SQL Server 2005 DATETIME always includes a time. If you check for exact match with just the date part, you'll get only rows that match with a time of 0:00:00 - nothing else.

You can either use any of the recommend range queries mentioned, or in SQL Server 2008, you could use the DATE only date time - or you could do a check something like:

select * from tblErrorLog
where DAY(errorDate) = 20 AND MONTH(errorDate) = 12 AND YEAR(errorDate) = 2008

Whichever works best for you.

If you need to do this query often, you could either try to normalize the DATETIME to include only the date, or you could add computed columns for DAY, MONTH and YEAR:

ALTER TABLE tblErrorLog
   ADD ErrorDay AS DAY(ErrorDate) PERSISTED
ALTER TABLE tblErrorLog
   ADD ErrorMonth AS MONTH(ErrorDate) PERSISTED
ALTER TABLE tblErrorLog
   ADD ErrorYear AS YEAR(ErrorDate) PERSISTED

and then you could query more easily:

select * from tblErrorLog
where ErrorMonth = 5 AND ErrorYear = 2009

and so forth. Since those fields are computed and PERSISTED, they're always up to date and always current, and since they're peristed, you can even index them if needed.

🌐
Datameer
datameer.com › home › blog › how to get only the date part from the datetime in sql server and snowflake
How to get only the DATE part from the DATETIME in SQL Server and Snowflake
November 3, 2023 - In SQL Server 2008 and above, we can either use the CONVERT or CAST function to return the DATE part from the DATETIME datatype.
🌐
SQLTeam
forums.sqlteam.com › transact-sql
SELECT Datetime values using where clause - Transact-SQL - SQLTeam.com Forums
April 24, 2017 - CREATE TABLE TEST.[dbo].[dt] ( [TRAN DATE] datetime ) INSERT INTO TEST.[dbo].[dt] ([TRAN DATE]) VALUES ('2017-01-01 08:24:03.000'), ('2017-01-03 10:24:03.000'), ('2017-02-10 09:50:03.000'), ('2017-03-05 12:24:03.000'), ('2017-04-17 20:24:03.000') ...
🌐
Sentry
sentry.io › sentry answers › sql server › how to return only the date from a sql server datetime datatype
How to return only the date from a SQL Server DateTime datatype | Sentry
If you are using an old version of SQL Server then the date type isn’t available since only datetime is supported. You have to use the following code to remove the time portion from the date: SELECT DATEADD(dd, 0, DATEDIFF(dd, 0, GETDATE())); -- ...
🌐
Baeldung
baeldung.com › home › sql queries › how to select a date without including the time in sql
How to Select a Date Without Including the Time in SQL Baeldung on SQL
May 16, 2025 - We do this by formatting the DATETIME value to display only dates in our query. For example, let’s explore how to use the DATE_FORMAT() function to select a date without including the time in SQL:
Find elsewhere
🌐
Sqlzap
sqlzap.com › blog › select-date-from-datetime-in-sql
Select date from datetime in SQL
SELECT * FROM your_table WHERE CAST(datetime_column AS DATE) BETWEEN '2024-09-01' AND '2024-09-30'; This query will return all records with dates in September 2024, ignoring the time component 1. To work with the current date, most SQL databases provide functions like GETDATE() (SQL Server) ...
🌐
GoLinuxCloud
golinuxcloud.com › home › sql › how to precisely get date from datetime sql? [7 methods]
How to Precisely Get Date from DateTime SQL? [7 Methods] | GoLinuxCloud
October 19, 2023 - TRY_CONVERT() Function: Employ the TRY_CONVERT() function to safely attempt a conversion from DateTime to Date data type, ensuring that only the date part is retrieved while providing null for unsuccessful conversions, enhancing query reliability ...
🌐
Josip Miskovic
josipmisko.com › posts › sql-get-date-from-datetime
SQL: How to Get Date from DateTime? | 2 Simple Ways – Josip Miskovic
March 30, 2023 - In SQL Server, the two most popular ways to get Date from DateTime are CAST and CONVERT functions.
🌐
DB Vis
dbvis.com › thetable › extracting-time-and-date-in-ms-sql-server-a-comprehensive-guide
Extract Date and Time in MS SQL Server: A Complete Guide
February 7, 2025 - CAST is a function in SQL Server that allows you to change the data type of an expression. It can be used to extract time from the datetime function or convert datetime values to date-only formats.
Top answer
1 of 2
127

The fastest if you have to iterate over a recordset and don't have date in SQL Server 2008

SELECT DATEADD(day, DATEDIFF(day, 0, GETDATE()), 0)

Two different and excellent answers on StackOverflow bear this out: One, Two

Varchar conversions are one of the worst ways to do it. Of course, for one value it may not matter but it's a good habit to get into.

This way is also deterministic, say if you want to index a computed column. Even folk who write books about SQL Server get caught out with datetime conversions

This technique is also extendable.

  • yesterday: DATEADD(day, DATEDIFF(day, 0, GETDATE()), -1)
  • start of month: DATEADD(month, DATEDIFF(month, 0, GETDATE()), 0)
  • end of last month: DATEADD(month, DATEDIFF(month, 0, GETDATE()), -1)
  • start of next month: DATEADD(month, DATEDIFF(month, 0, GETDATE()), 31)

Edit:

As I mentioned about determinism, varchar methods are not safe unless you use style 112.

Other answers here point out that you'd never apply this to a column. This is correct, but you may want to select a 100k rows or add a computed column or GROUP BY dateonly. Then you have to use this method.

The other answer also mentions style 110. This is not language or SET DATEFORMAT safe and fails with "british" language setting. See the ultimate guide to the datetime datatypes by Tibor Karaszi.

2 of 2
7

You have to convert it to varchar specifying a format pattern (110 in this case) then convert (or cast) back to datetime.

select getdate(), cast(convert(varchar(10), getdate(), 110) as datetime)
🌐
JanBask Training
janbasktraining.com › community › sql-server › how-to-return-only-the-date-from-a-sql-server-datetime-datatype1
How to return only the Date from a SQL Server DateTime datatype | JanBask Training Community
August 16, 2025 - Use string formatting only when you need the date in a specific textual format. In short, CAST(GETDATE() AS DATE) or CONVERT(DATE, GETDATE()) are the cleanest ways to return only the date from a DateTime value in SQL Server.
🌐
LearnSQL.com
learnsql.com › cookbook › how-to-get-the-date-from-a-datetime-column-in-mysql
How to Get the Date from a Datetime Column in MySQL | LearnSQL.com
We’ll use the DATE() function. Here’s the query you would write: SELECT first_name, last_name, DATE(timestamp_of_booking) AS date_of_booking FROM travel; ... In MySQL, use the DATE() function to retrieve the date from a datetime or timestamp value...
🌐
GeeksforGeeks
geeksforgeeks.org › sql › sql-query-to-convert-datetime-to-date
SQL Query to Convert DateTime to Date in SQL Server - GeeksforGeeks
Explanation: In this example, we first CONVERT() the current DateTime to a varchar string with format 23 (YYYY-MM-DD), then use SUBSTRING() to get only the date part. Converting DateTime to Date in SQL Server is a straightforward process that ...
Published   July 23, 2025