Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2000 Forums
 Transact-SQL (2000)
 Select Time only of datetime type

Author  Topic 

Session101
Starting Member

15 Posts

Posted - 2004-07-27 : 17:42:52
Hey guys,

I have a datetime field, i.e. July 27, 2004 9:30AM. I would like to extract only the time portion of this field. How do you do it while retaining the AM/PM portion? Thanks!

Pat Phelan
Posting Yak Master

187 Posts

Posted - 2004-07-27 : 18:10:50
I'd use:
SELECT SubString(Convert(VARCHAR(30), GetDate(), 100), 13, 109)
-PatP
Go to Top of Page

Session101
Starting Member

15 Posts

Posted - 2004-07-27 : 18:16:44
Thanks Pat! I can't believe I completely forgot to use substring...
Go to Top of Page

Pat Phelan
Posting Yak Master

187 Posts

Posted - 2004-07-27 : 18:17:37
Some days it is the really simple things that hang us up!

-PatP
Go to Top of Page
   

- Advertisement -