How to: Query Time only?
Hi,
I would just like to know if there's a simple way of querying a time disregarding the date. I mean, I want to query all employees that spends time on the office after 5pm. I don't care about the date, I just want the time... Im currently achieving this by using DATEPART function and concatenating it to resemble a time. Is there a shorter way of doing this?
cheers,
Paul June A. Domag
FWIW, here's another variation on that topic:
SELECT RIGHT(STUFF(CONVERT(CHAR(22),GETDATE(),13),21,4,' '),9)
08:25:36
(1 row(s) affected)
And in case your HR department wants to track the overtime down to milliseconds, you can do:
SELECT CONVERT(CHAR(12),GETDATE(),114)
08:25:36:093
(1 row(s) affected)
--
Frank Kalis
Microsoft SQL Server MVP
http://www.insidesql.de
Ich unterstütze PASS Deutschland e.V. (http://www.sqlpass.de)