+ Reply to Thread
Results 1 to 3 of 3

convert number (integer) into hour:minute:seconds

Hybrid View

  1. #1
    Valued Forum Contributor
    Join Date
    11-20-2003
    MS-Off Ver
    2010, 2016
    Posts
    1,176

    convert number (integer) into hour:minute:seconds

    I am trying to convert a column of numbers into hours:minutes:seconds.

    For example, I have following numbers (original data followed by desired output). I tried using the custom number format but could not get the desired result. Any assistance appreciated.

    9 - convert to :09
    53 - convert to :53
    68 - convert to 1:08
    109 - convert to 1:49
    121 - convert to 2:01
    262 - convert to 4:22
    Last edited by maacmaac; 06-01-2011 at 08:57 AM.

  2. #2
    Forum Expert davegugg's Avatar
    Join Date
    12-18-2008
    Location
    WI, US
    MS-Off Ver
    2010
    Posts
    1,884

    Re: convert number (integer) into hour:minute:seconds

    This will get it to hours, minutes, and seconds.

    =TEXT(ROUNDDOWN(A1/3600,0),"00") & ":" &TEXT(ROUNDDOWN(MOD(A1,3600)/60,0),"00") & ":"&TEXT(MOD(A1,60),"00")
    This assumes your list starts in cell A1, then just copy down.

    To get rid of leading zeros, you could add an if function, but it becomes complicated:

    =IF(A1<60,":"&TEXT(MOD(A1,60),"00"),IF(A1<3600,TEXT(ROUNDDOWN(MOD(A1,3600)/60,0),"00")&":"&TEXT(MOD(A1,60),"00"),TEXT(ROUNDDOWN(A1/3600,0),"00")&":"&TEXT(ROUNDDOWN(MOD(A1,3600)/60,0),"00")&":"&TEXT(MOD(A1,60),"00")))
    Is your code running too slowly?
    Does your workbook or database have a bunch of duplicate pieces of data?
    Have a look at this article to learn the best ways to set up your projects.
    It will save both time and effort in the long run!


    Dave

  3. #3
    Valued Forum Contributor
    Join Date
    11-20-2003
    MS-Off Ver
    2010, 2016
    Posts
    1,176

    Re: convert number (integer) into hour:minute:seconds

    Thanks for comments. I modified slightly and using following formula (formula assumes no values greater than or equal to 60 minutes).
    =IF(A2<60,TEXT(A2/(24*60*60),":ss"),TEXT(A2/(24*60*60),"m:ss"))

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

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

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1