The TIME data type in SQL Server 2008 (and later)

Similarly to my previous post about the DATE data type in SQL Server 2008 and later, another data type, which was originally shipped in SQL Server 2008 is the “TIME” data type.

Again, without having to manipulate the current datetime for getting the time, you just have to cast it to the TIME data type. Here’s the syntax:

SELECT CAST(SYSDATETIME() as TIME) as [current_time];
GO

or

SELECT CAST(GETDATE() as TIME) as [current_time];
GO

 

Learn more tips like this!
Enroll to our Online Course!

Check our online course titled “Essential SQL Server Development Tips for SQL Developers” (special limited-time discount included in link).

Sharpen your SQL Server database programming skills via a large set of tips on T-SQL and database development techniques. The course, among other, features over than 30 live demonstrations!

Essential SQL Server Development Tips for SQL Developers - Online Course

Learn More

 

 

Featured Online Courses:

 

Read Also:

 

Featured Database Productivity Tools

Snippets Generator: Create and modify T-SQL snippets for use in SQL Management Studio, fast, easy and efficiently.

Snippets Generator - SQL Snippets Creation Tool

Learn more

 

Dynamic SQL Generator: Convert static T-SQL code to dynamic and vice versa, easily and fast.

Dynamic SQL Generator: Easily convert static SQL Server T-SQL scripts to dynamic and vice versa.

Learn more

 

Subscribe to our newsletter and stay up to date!

Check out our latest software releases!

Check out Artemakis’s eBooks!

 

Rate this article: 1 Star2 Stars3 Stars4 Stars5 Stars (2 votes, average: 5.00 out of 5)

Loading...

Reference: SQLNetHub.com (https://www.sqlnethub.com)

© SQLNetHub