How to see this format hh:mm from hh:mm:ss in SQL Server 2008 query?
How to see this format hh:mm
from hh:mm:ss
in SQL开发者_Go百科 Server 2008 query ?
There's no direct, built-in functionality for this.
Assuming you have a DATETIME
or TIME
column in SQL Server, you need to hack it like this:
SELECT
SUBSTRING(CONVERT(VARCHAR(20), YourDateTimeColumn, 108), 1, 5)
The CONVERT
statement with style = 108 will convert your date to hh:mm:ss
and then you just chop off the last three characters.
Things like this really shouldn't be done in the database - that's purely presentation logic, and it belongs in the UI app.
精彩评论