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 2008 Forums
 Transact-SQL (2008)
 Select Time Field as HH only

Author  Topic 

robnjay
Starting Member

14 Posts

Posted - 2012-09-20 : 10:27:09
I need to select records from a field which has times like

06:05:59

I need to select only the hours and add ":00:00" to it, so my query retrieves

06:00:00

I am using SQL Server 2000

In another SQL (not SQL Server), I had a FORMAT, so I could do:
CAST([Date] as CHAR FORMAT 'DD-MON-YY HH:00:00') as TheTime

How do I do this in SQL Server 2000? I don't think I can use the canned formatting numbers in this case...

Edit: I now realize this should have been in another area of the forum, can't figure out how to move it to the SQL Server 2000 Transact SQL area...


Thanks

khtan
In (Som, Ni, Yak)

17689 Posts

Posted - 2012-09-20 : 10:57:14
[code]select convert(varchar(3), getdate(), 108) + '00:00'[/code]


KH
[spoiler]Time is always against us[/spoiler]

Go to Top of Page
   

- Advertisement -