Results 1 to 3 of 3

Thread: Convert Number to Time

  1. #1
    Join Date
    Sep 2003
    Location
    UK
    Posts
    14

    Convert Number to Time

    In my database times are stored as integers. Therefore if someone arrives a 1am the value is 60, 2am 120 etc. Is there a way to convert these integer values to 1:00, 2:00. I've tried converting to a decimal so if somene arrives at 1:30 it returns 1.5, but I still only get the integer value...

    CONVERT(decimal(10,2), (90/60)) AS iStart

    Thanks in advance
    Roy

  2. #2
    Join Date
    Sep 2002
    Posts
    5,938
    CONVERT(decimal(10,2), (90.0/60)) AS iStart

  3. #3
    Join Date
    Dec 2004
    Posts
    502
    You can convert directly to datetime format like this:

    SELECT CONVERT(varchar, DATEADD(second, 60, 0), 108)
    SELECT CONVERT(varchar, DATEADD(second, 120, 0), 108)

Posting Permissions

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