---
title: "What is the best way to remove the time part of datetime in SQL Server?"  
description: "What is the best way to remove the time part of datetime in SQL Server?"  
author: "Revati S Misra"  
published: 2023-07-11  
updated: 2023-07-12  
canonical: https://www.mindstick.com/forum/159041/what-is-the-best-way-to-remove-the-time-part-of-datetime-in-sql-server  
category: "mssql server"  
tags: ["mssql server", "sql server", "sql"]  
reading_time: 2 minutes  

---

# What is the best way to remove the time part of datetime in SQL Server?

What is the best way to [remove](https://yourviews.mindstick.com/story/4554/8-harmful-weeds-to-remove-from-garden) the time part of [datetime](https://www.mindstick.com/forum/12949/how-to-validate-if-a-datetime-field-is-not-null-empty) in [SQL Server](https://www.mindstick.com/articles/12999/what-is-table-valued-function-in-sql-server)?

## Replies

### Reply by Aryan Kumar

There are three ways to remove the time part of a datetime in [SQL](https://www.mindstick.com/articles/13115/types-of-keys-in-sql-or-oracle-database) [Server](https://www.mindstick.com/articles/43769/what-is-serverless-architecture-is-it-worth-switching-over):

- **Use the** `DATE` **data type**

The `DATE` data type only stores the date part of a datetime value. To use the `DATE` data type, you need to cast the datetime value to `DATE`. For example, the following code will remove the time part of the datetime value `2023-07-12 08:00:25`:

SQL

```plaintext
SELECT CAST('2023-07-12 08:00:25' AS DATE);
```

- **Use the** `CONVERT` **function**

The `CONVERT` function can be used to convert a datetime value to a different data type. To remove the time part of a datetime value, you can use the `CONVERT` function to convert the datetime value to the `DATE` data type. For example, the following code will remove the time part of the datetime value `2023-07-12 08:00:25`:

SQL

```plaintext
SELECT CONVERT(DATE, '2023-07-12 08:00:25');
```

- **Use the** `SUBSTRING` **function**

The `SUBSTRING` function can be used to extract a substring from a string. To remove the time part of a datetime value, you can use the `SUBSTRING` function to extract the first 10 characters from the datetime value. The first 10 characters of a datetime value represent the date part of the datetime value. For example, the following code will remove the time part of the datetime value `2023-07-12 08:00:25`:

SQL

```plaintext
SELECT SUBSTRING('2023-07-12 08:00:25', 1, 10);
```

The best way to remove the time part of a datetime in SQL Server depends on your specific needs. If you need to store the date part of the datetime value in a separate column, you can use the `DATE` data type. If you need to store the date part of the datetime value in the same column, you can use the `CONVERT` function or the `SUBSTRING` function.


---

Original Source: https://www.mindstick.com/forum/159041/what-is-the-best-way-to-remove-the-time-part-of-datetime-in-sql-server

Copyright © MindStick Software Pvt. Ltd. This Markdown version is provided for developers, AI systems, and offline reading.
