Convert Cumulative Time / Time Duration to Text or String

bemp87

Board Regular
Joined
Dec 10, 2016
Messages
100
I have a Cumulative Time field that formats as [h]:mm:ss that aggregates time in hours. I am needing to extract the time portion to convert it to a Text or String value. For example, a cumulative time total of 95:31:00 shows as "1/3/1900 11:31:00 PM" in the formula bar which is not what i want. The value 95:31:00 is what i need to load into an MSFT Access database, but it does not accept cumulative totals, so i've been having to convert it manually which is coming extremely time consuming by using the following formula: ="95:31:00". This gets almost impossible when I am working with many rows.

I have tried the TRUNC() function for this and cannot seem to get this to work. Any help would be appreciated.
 

Attachments

  • Mr Excel Help_1.png
    Mr Excel Help_1.png
    179.3 KB · Views: 3

Excel Facts

Enter current date or time
Ctrl+: enters current time. Ctrl+; enters current date. Use Ctrl+: Ctrl+; Enter for current date & time.

shaowu459

Well-known Member
Joined
Apr 26, 2018
Messages
534
Office Version
  1. 365
Platform
  1. Windows

bemp87

Board Regular
Joined
Dec 10, 2016
Messages
100
Wow. I'm annoyed with myself, I tried this exact thing but left off the square brackets around hh that resulted in the wrong value. This works perfectly and solves a week long headache and has just saved me an insurmountable amount of work. Thank you!!!
 

shaowu459

Well-known Member
Joined
Apr 26, 2018
Messages
534
Office Version
  1. 365
Platform
  1. Windows
Wow. I'm annoyed with myself, I tried this exact thing but left off the square brackets around hh that resulted in the wrong value. This works perfectly and solves a week long headache and has just saved me an insurmountable amount of work. Thank you!!!
Glad to know you solved the problem :giggle:
 

bemp87

Board Regular
Joined
Dec 10, 2016
Messages
100
I'm Curious, is this possible to do programmitcally using vba? I have the following code but it keeps inserting the value as a datetime format instead of a string? The Timestring is not returning as an actual string value capturing the values as "[hh]:mm:ss". What am i Doing Wrong?

VBA Code:
Sub DataCleanse()
    Dim RowNum As Long
    Dim CpH As Double
    Dim StatDate As Date
    Dim EomFlag As Integer
    Dim TimeString As String
  
  
    StatDate = "05/22/2020"
    EomFlag = 0
    RowNum = 2
    For RowNum = 2 To 19
        CpH = Round(Cells(RowNum, 13).Value / (Cells(RowNum, 11).Value * 24), 2)
        TimeString = WorksheetFunction.Text(Cells(RowNum, 11), "[h]:mm:ss")
        Cells(RowNum, 15).Value = CpH
        Cells(RowNum, 16).Value = StatDate
        Cells(RowNum, 17).Value = EomFlag
    Next RowNum
End Sub
 

Watch MrExcel Video

Forum statistics

Threads
1,130,091
Messages
5,640,059
Members
417,125
Latest member
sfreind

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Top