Intellipaat Back

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

I want only Time from the DateTime column using SQL query using SQL Server 2005 and 2008.

Default output:

AttDate                   
==
2011-02-09 13:09:00 
2011-02-09 14:10:00 

I want the output to be:

AttDate                Time 
==
2011-02-09 13:09:00   13:09
2011-02-09 14:10:00   14:10

1 Answer

0 votes
by (12.7k points)

SQL Server 2008:

SELECT cast(AttDate as time) [time]

FROM yourtable

Earlier versions:

SELECT convert(char(5), AttDate, 108) [time]

FROM yourtable

Interested in SQL ? Check out this SQL Certification by Intellipaat.

For more information visit :

Related questions

0 votes
1 answer
0 votes
1 answer
0 votes
1 answer
asked Jul 30, 2019 in SQL by Tech4ever (20.3k points)
0 votes
1 answer

31k questions

32.8k answers

501 comments

693 users

Browse Categories

...