Back

Explore Courses Blog Tutorials Interview Questions
0 votes
2 views
in SQL by (6.1k points)

In SQL Server, In a table, I have a time field that I need to display in a view in hh:mm format. 

What can be the most simplistic way to do this?

1 Answer

0 votes
by (12.7k points)

You can use the below code:

SELECT CONVERT(VARCHAR(5), GETDATE(), 108)

RESULT:  13:19

For Time values

DECLARE @TimeField TIME = CAST(GETDATE() AS TIME);

SELECT CONVERT(VARCHAR(5), @TimeField, 108)

RESULT:  13:21

Kick-start your career in SQL with the perfect SQL Training Course now!

Watch the below SQL video tutorial to gain more knowledge on SQL...

Related questions

0 votes
1 answer
0 votes
1 answer
asked Dec 30, 2020 in SQL by Appu (6.1k points)
0 votes
1 answer

Browse Categories

...