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 2005 Forums
 Transact-SQL (2005)
 Getting time from date/time column

Author  Topic 

w_cohen
Starting Member

6 Posts

Posted - 2008-05-16 : 13:23:00
How can I obtain just the time portion from a date/time column?
My data contains "2008-05-19 09:30:00.000"
Actually, all I want/need is the hh:mm part of it.

Thanks,
Walt

tkizer
Almighty SQL Goddess

38200 Posts

Posted - 2008-05-16 : 13:26:07
DECLARE @dt datetime
SET @dt = '2008-05-19 09:30:00.000'
SELECT LEFT(CONVERT(varchar(50), @dt, 108), 5)

Tara Kizer
Microsoft MVP for Windows Server System - SQL Server
http://weblogs.sqlteam.com/tarad/

Database maintenance routines:
http://weblogs.sqlteam.com/tarad/archive/2004/07/02/1705.aspx
Go to Top of Page

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2008-05-16 : 13:27:16
Use LEFT(CONVERT(varchar(20),yourdatecolumn,108),5)
Go to Top of Page
   

- Advertisement -