SA Developer .NET

Welcome to SA Developer .NET Sign in | Join | Help
in Search

Convert to hours

Last post 08-11-2008, 16:05 by GilaMonster. 1 replies.
Sort Posts: Previous Next
  •  08-11-2008, 15:46 13959

    Convert to hours

    Hi all...can any1 plz assist me with converting this value "86400000" milliseconds into hours and minutes
    Livin life on da flip side
  •  08-11-2008, 16:05 13960 in reply to 13959

    Re: Convert to hours

    This should work. It takes advantage of the integer division in SQL, that's why there's an apparently pointless divide and multiply in the second clause

    DECLARE @Milliseconds INT,
        @Minutes INT
    SET @Milliseconds = 86400000
    SET @Minutes = @Milliseconds/60000

    select @Minutes/60 AS Hours, @Minutes - (@Minutes/60)*60 AS Minutes


    Gail Shaw - SQL In the Wild
    SQL Server MVP
    --
    Chaos, panic and disorder. My job here is done!
View as RSS news feed in XML
Powered by Community Server (Commercial Edition), by Telligent Systems