Search code examples
sql-servert-sqlsql-server-2008datetime-format

SQL Server 2008: display time in hh:mm format


I have a time field in a table that I would like to display in a view in hh:mm format. What is the easiest way to do this?


Solution

  • SELECT CONVERT(VARCHAR(5), GETDATE(), 108)
    
    RESULT:  13:19
    

    For Time values

    DECLARE @TimeField TIME = CAST(GETDATE() AS TIME);
    
    SELECT CONVERT(VARCHAR(5), @TimeField, 108)
    
    RESULT:  13:21