Truncating dates in SQL Server is a common task for developers working with SQL Server. In this comprehensive article, I will walk you through everything you need to know about truncating dates in SQL Server with multiple approaches.
Trunc Date In SQL Server
SQL Server 2022 introduced the DATETRUNC function, which simplifies date truncation operations. This function returns a truncated date of the same data type as the input date. In addition to this function, there are other methods available to achieve the same goal.
Method-1 Using DATETRUNC ()
The most straightforward approach is to use the DATETRUNC () for this purpose.
Examples
We can execute the following query to truncate to the month.
SELECT DATETRUNC(month, '2025-04-18 14:30:25');Similarly, to truncate to a quarter, you can use the following query.
SELECT DATETRUNC(quarter, '2025-04-18 14:30:25');Now, to truncate to the year, you can use the following query.
SELECT DATETRUNC(year, '2025-04-18 14:30:25');You can check out the SQL Server DATETRUNC Function for more information.
If you’re using an older version of SQL Server, you don’t have direct access to the DATETRUNC function. So in that case, you can use the following methods.
Method 2: Using DATEADD and DATEDIFF
Example-1:
You can use the below query to truncate to a month using the DATEADD and DATEDIFF functions.
SELECT DATEADD(MONTH, DATEDIFF(MONTH, 0, GETDATE()), 0);After executing the above query, I got the expected output as shown in the screenshot below.

Example-2:
You can use the below query to truncate to day.
SELECT DATEADD(DAY, DATEDIFF(DAY, 0, GETDATE()), 0);After executing the above query, I got the expected output as shown in the screenshot below.

Example-3:
You can use the below query to truncate a year.
SELECT DATEADD(YEAR, DATEDIFF(YEAR, 0, GETDATE()), 0);After executing the above query, I got the expected output as shown in the screenshot below.

Method 2: Using CAST or CONVERT
Example-1:
We can truncate to day using CONVERT function using the below query.
SELECT CONVERT(DATE, GETDATE());After executing the above query, I got the expected output as shown in the screenshot below.

Example-2:
We can truncate to day using CAST function using the below query.
SELECT CAST(GETDATE() AS DATE);I got the expected output after executing the above query as shown in the screenshot below.

Method 3: Using Custom Calculations
We can use the below query to get the first day of current month.
SELECT DATEADD(MONTH, DATEDIFF(MONTH, 0, GETDATE()), 0);After executing the above query, I got the expected output as shown in the screenshot below.

Simmilarly, We can use the below query to get the first day of current quarter.
SELECT DATEADD(QUARTER, DATEDIFF(QUARTER, 0, GETDATE()), 0);I got the expected output as shown in the below screenshot.

Performance Suggestion
Below are some suggestions.
- Indexing: Ensure your date columns are properly indexed, especially if you frequently filter or group by truncated dates
- Computed Columns: For frequently used truncation operations, consider adding calculated columns.
-- Add a computed column
ALTER TABLE Transactions
ADD TransactionMonth AS DATETRUNC(month, TransactionDate);
- DATETRUNC vs. DATEADD/DATEDIFF: In SQL Server 2022+, DATETRUNC is generally more efficient than the DATEADD/DATEDIFF combination as it’s specifically optimized for this purpose
Conclusion
Date truncation in SQL Server is a fundamental skill for a developer. The new DATETRUNC function significantly simplifies these operations in SQL Server 2022, but for older versions, you can also use the above methods mentioned in this article.
You may also like the following articles below
- SQL Server Get UTC Date
- SQL Server Date Compare
- SQL Server GROUP BY Date
- SQL Server Add Days To Date
- SQL Server MAX Date
After working for more than 15 years in the Software field, especially in Microsoft technologies, I have decided to share my expert knowledge of SQL Server. Check out all the SQL Server and related database tutorials I have shared here. Most of the readers are from countries like the United States of America, the United Kingdom, New Zealand, Australia, Canada, etc. I am also a Microsoft MVP. Check out more here.