One of the new data types originally shipped with SQL Server 2008 is the “DATE” data type.
The DATE data type provides only the date without requiring from the database developers to extract the date from the datetime anymore.
To this end you can just get the date with a single line of code:
SELECT CAST (SYSDATETIME() as DATE) as [current_date]; GO
or
SELECT CAST(GETDATE() as DATE) as [current_date]; GO
Read Also:
- The TIME data type in SQL Server 2008
- The set identity_insert Command in SQL Server
- How to Import and Export Unstructured Data in SQL Server – FileTables
- How to Import and Export Unstructured Data in SQL Server – FILESTREAM
- How to Import and Export Unstructured Data in SQL Server – The IMAGE Datatype
- T-SQL Tip: Inserting Leading Characters to a String
- T-SQL Tip: Getting all the Records from all Tables in all User Databases
- … all SQL Server development articles
Featured Database Productivity Tools
Snippets Generator: Create and modify T-SQL snippets for use in SQL Management Studio, fast, easy and efficiently.
Dynamic SQL Generator: Convert static T-SQL code to dynamic and vice versa, easily and fast.
Subscribe to our newsletter and stay up to date!
Check out our latest software releases!
Check out Artemakis’s eBooks!
Rate this article:
Reference: SQLNetHub.com (https://www.sqlnethub.com)
© SQLNetHub
Artemakis Artemiou, a distinguished Senior Database and Software Architect, brings over 20 years of expertise to the IT industry. A Certified Database, Cloud, and AI professional, he earned the Microsoft Data Platform MVP title for nine consecutive years (2009-2018). As the founder of SQLNetHub and GnoelixiAI Hub, Artemakis is dedicated to sharing his knowledge and democratizing education on various fields such as: Databases, Cloud, AI, and Software Development. His commitment to simplicity and knowledge sharing defines his impactful presence in the tech community.