Results 1 to 3 of 3
  1. #1
    Join Date
    Jan 2003
    Location
    Atlanta
    Posts
    134

    Unanswered: convert seconds into format hh:mm:ss

    Is there a simple way to convert seconds (integer) number into the format hh:mm:ss format in SQL2000 query analyzer?

  2. #2
    Join Date
    Feb 2002
    Location
    Houston, TX
    Posts
    809
    try this...

    Code:
    declare @h int, @m int, @s int
    set @s = 9003
    set @h = @s/360
    set @s = @s - (@h * 360)
    set @m = @s / 60
    set @s = @s - (@m * 60)
    select right("00" + cast(@h as varchar),2) + ":" + right("00" + cast(@m as varchar),2) + ":" + right("00" + cast(@s as varchar),2)
    Paul Young
    (Knowledge is power! Get some!)

  3. #3
    Join Date
    Apr 2003
    Posts
    18

    Re: convert seconds into format hh:mm:ss

    Originally posted by vkaramched
    Is there a simple way to convert seconds (integer) number into the format hh:mm:ss format in SQL2000 query analyzer?
    Hi vkaramched, Try This.

    Declare @pvsSeconds INT

    Set @pvsSeconds = 4754395
    CASE WHEN (@pvsSeconds/3600) <=9 THEN '0' ELSE '' END + CONVERT(VARCHAR, (@pvsSeconds/3600)) + ':' + RIGHT('100' + CONVERT(VARCHAR, (@pvsSeconds%3600)/60),2) + ':' + RIGHT('100' + CONVERT(VARCHAR, @pvsSeconds%60),2)


    Cheers,
    Gola Munjal

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •