Query: How to select Time only from a datetime field?

How to select only time from a datetime field?

I have a datetime field named SentTime.
I only want to select the Time from the field..

sample data of TimeSent:
21/09/2004 12:58:41 PM

But I only want to select 12:58:41 PM...
how to do it?
p931226Asked:
Who is Participating?

[Webinar] Streamline your web hosting managementRegister Today

x
 
appariConnect With a Mentor Commented:
use convert function.

eg:
select convert(varchar,getDate(),108)

in your sql

Select convert(varchar,SentTime,108) from yourTable
0
 
p931226Author Commented:
Hi, appari
I follow ur method, it shown
19:00:00

Any method that will make it shown like:
07:00:00 PM ???

Thanks.

0
 
appariCommented:
i think no direct way
try like this

select substring(convert(varchar,getdate(),100),13,9)
0
 
p931226Author Commented:
thanks, appari..
0
All Courses

From novice to tech pro — start learning today.