Fastest way to strip time component from datetime values in SQL Server

I’m working with a large dataset and need to extract just the date part from datetime columns. I’ve been testing different methods but I’m not sure which one performs best with lots of records.

Method 1:

select DATEADD(day, DATEDIFF(day, 0, current_timestamp), 0)

Method 2:

select cast(convert(varchar(12), current_timestamp, 101) as datetime)

Both approaches seem quick on small datasets, but I’m concerned about performance when processing thousands of rows. The convert method might use slightly more memory due to string conversion, but maybe that’s not the main bottleneck.

Has anyone compared these methods on large tables? Are there other techniques that might work even faster for removing time portions from datetime fields?

i usually go with CONVERT(date, your_datetime_column) too, way quicker than the other methods. also more straightforward! sql server does it well even with huge tables full of records. give it a try!

You’re right that DATEADD/DATEDIFF is one of the fastest methods for SQL Server before 2008. But if you’re on SQL Server 2008 or later, just use CAST(datetime_column AS DATE) or CONVERT(DATE, datetime_column) - they’ll beat both methods you tested. These skip all the math calculations and string conversions. I’ve tested this on tables with millions of records, and native DATE casting consistently runs faster with less CPU usage. The performance gap gets even bigger when you use it in WHERE clauses or JOINs, so keep that in mind for your situation.

Oh interesting! Have you tried CAST(your_datetime AS DATE)? I’m curious how it compares to DATEDIFF. What’s your dataset size - millions of rows? Also wondering if indexing affects performance between these methods.