+ Reply to Thread
Results 1 to 8 of 8

Days, hours, minutes and seconds

Hybrid View

  1. #1
    Registered User
    Join Date
    03-24-2007
    Posts
    88

    Days, hours, minutes and seconds

    Does any know how I can convert 29.18:20:18 to total minutes?
    Last edited by oldchippy; 10-23-2008 at 04:09 PM.

  2. #2
    Valued Forum Contributor
    Join Date
    09-19-2008
    Location
    It varies ...
    MS-Off Ver
    Office365 - 64bit
    Posts
    862
    Hi Nunzio - you'll have to parse the string like this:

    Private Sub DaysHoursMinsSecs()
    
    Dim lngDays As Long
    Dim lngHours As Long
    Dim lngMins As Long
    Dim lngSecs As Long
    Dim strDaySeparator As String
    Dim strTimeSeparator As String
    Dim strData As String
    Dim lngMinutes As Long
    
        strData = Range("A1").Text
        strDaySeparator = "."
        strTimeSeparator = ":"
        
        lngDays = Left(strData, InStr(strData, strDaySeparator) - 1)
        strData = Right(strData, Len(strData) - InStr(strData, strDaySeparator))
        
        lngHours = Left(strData, InStr(strData, strTimeSeparator) - 1)
        strData = Right(strData, Len(strData) - InStr(strData, strTimeSeparator))
        
        lngMins = Left(strData, InStr(strData, strTimeSeparator) - 1)
        strData = Right(strData, Len(strData) - InStr(strData, strTimeSeparator))
        
        lngSecs = CInt(strData)
        
        lngMinutes = (lngDays * 24 * 60) + (lngHours * 60) + (lngMins) + (lngSecs / 60)
    
    End Sub
    Depending on how you want to use it, you might want to convert it to a function for use in the sheet.

    Hope that helps. MM.

  3. #3
    Registered User
    Join Date
    03-24-2007
    Posts
    88

    code

    MM
    I am not sure how to
    End SubDepending on how you want to use it, you might want to convert it to a function for use in the sheet.

  4. #4
    Registered User
    Join Date
    03-24-2007
    Posts
    88

    code

    Can anyone make this easier, I want to convert B1 through B8 from the days, hours, minutes and seconds to just the number of total minutes.

    Thanks

  5. #5
    Forum Expert daddylonglegs's Avatar
    Join Date
    01-14-2006
    Location
    England
    MS-Off Ver
    Microsoft 365
    Posts
    14,704
    Do you need VBA or will a formula suffice?

    Assuming B1 is a text string then try this formula in C1

    =(LEFT(A1,FIND(".",B1)-1)+RIGHT(B1,8))*1440

  6. #6
    Registered User
    Join Date
    03-24-2007
    Posts
    88
    A formula will work but I have to be able to calculate each cell (B1-B12) separately, and each cell could be a different variation of time, they could be any variation of days, hours, minutes, and seconds.

    Machine Down
    Assembler 07:43:45
    Bottle Sorter 13:57:17
    Cap Sorter 04:02:05
    Cartoner 1.09:45:48
    Case Packer 15:38:40
    Depucker 12:45:12
    Filler 19:49:23
    Line 00:00:00
    Pucker 10:29:08
    Sheath Sorter 01:16:12
    Tray Packer 11:57:48
    Wick Sorter 07:19:02

  7. #7
    Forum Expert oldchippy's Avatar
    Join Date
    02-14-2005
    Location
    Worcester, UK
    MS-Off Ver
    Excel 2007 (Home)
    Posts
    7,097
    Hi,

    Try this

    =IF(LEN(B2)=8,RIGHT(B2,8)*1440,(LEFT(B2,FIND(".",B2)-1)+RIGHT(B2,8))*1440)
    oldchippy
    -------------


    Blessed are those who can give without remembering and take without forgetting

    If you are happy with the help you have received, please click the <--- STAR icon on the left - Thanks.

    Click here >>> Top Excel links for beginners to Experts

    Forum Rules >>>Please don't forget to read these

  8. #8
    Registered User
    Join Date
    03-24-2007
    Posts
    88

    Thanks

    old chippy thanks a million.

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. Changing Seconds to minutes
    By phil2006 in forum Excel General
    Replies: 1
    Last Post: 08-27-2008, 05:01 PM
  2. changing seconds into hours and minutes
    By SJDANIELS in forum Excel Formulas & Functions
    Replies: 1
    Last Post: 08-01-2008, 08:30 AM
  3. convert seconds to minutes and seconds
    By Richard Flame in forum Excel General
    Replies: 3
    Last Post: 02-20-2007, 02:54 PM
  4. Which format to use for minutes and seconds?
    By guilbj2 in forum Excel General
    Replies: 2
    Last Post: 02-10-2007, 07:01 PM
  5. Convert Hours to Minutes and Seconds
    By Jenna11 in forum Excel General
    Replies: 10
    Last Post: 01-08-2007, 09:04 PM

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