How do I get the time only from a SQL datetime value?

I've googled this until my brain hurts and every example I try doesn't return the right thing.  I have this, in a datetime field:

'2007-03-17 13:25:00'

I need to query on the time only. (13:25:00)  How do I do this reliably?

Thanks!
Meshman333Asked:
Who is Participating?
 
waltersnowslinarnoldConnect With a Mentor Commented:
SELECT CONVERT(CHAR(10),GETDATE(),8)
0
 
Aneesh RetnakaranConnect With a Mentor Database AdministratorCommented:
Hello Meshman333,

select convert(varchar, datecolumn, 108 )

Regards,

aneeshattingal
0
 
sarabhaiConnect With a Mentor Commented:
using Convert function,

SELECT CONVERT(CHAR(10),GETDATE(),8)

SELECT CONVERT(CHAR(10),GETDATE(),14)

0
Cloud Class® Course: Microsoft Office 2010

This course will introduce you to the interfaces and features of Microsoft Office 2010 Word, Excel, PowerPoint, Outlook, and Access. You will learn about the features that are shared between all products in the Office suite, as well as the new features that are product specific.

 
Meshman333Author Commented:
Both of these return:

'2007-03-17 13:25:00'
0
 
waltersnowslinarnoldCommented:
Use your "date column name" where GetDate() is used.. you 'll reach the solution..
0
 
sarabhaiCommented:
Are u sure. In what version u run.
0
 
Meshman333Author Commented:
SELECT CONVERT(CHAR(10),GETDATE(),8)

SELECT CONVERT(CHAR(10),GETDATE(),14)

These return the date portion only.
0
 
waltersnowslinarnoldCommented:
SELECT CONVERT(CHAR(10),Your Date Column name,8)
0
 
Meshman333Author Commented:
This is Microsoft SQL Server 2008.
0
 
Meshman333Author Commented:
Sorry, they work, it's just me.  Thanks.
0
 
sarabhaiCommented:
SELECT CONVERT (time, GETDATE())
0
 
waltersnowslinarnoldCommented:
It has to work, Just give the column name, rather giving the '2007-03-17 13:25:00' value as such..
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.