Introduction to Remove Times from Dates in SQL Server
There are many approaches to remove Time from Date Columns with data and time. Below are the common approaches used now. This can vary for older SQL Versions.
- CAST To Date Data Type
- CONVERT Function with Style Code
- Format Function
Below is the sample data from EmployeesInfo with the ‘DateJoined‘ date time column. This data is used in the examples below.
How to Remove Times from Dates in SQL Server
In SQL Server, there are Date and DateTime data types to store Date and Time values. There can be situations when only the date value needs to be displayed or to do date calculations for date add, date difference functions, and between two dates from datetime values. So, to remove the Time part from dates with data and time, many methods can be used based on need and usage.
In this article, we will discuss methods such as CAST to Date Data Type, CONVERT Function with Style Code, and Format Function (For SQL Version 2012 and Later) to Remove Times from Dates in SQL Server in detail.