# Convert Unconventional D:H:M Counter to Total Minutes

#### jkerekgyarto

##### New Member
I need to convert these cells that contain elapsed time in the format shown, to total minutes.

The data in the cell is texts and numbers – there is a space on both sides of each number.

The formula is a Value function with a nested Find – it’s not working for me, however.

=VALUE(LEFT(A2,FIND("D",A2)-2))*24*60 + VALUE(LEFT(A2,FIND("D",A2)-3))*24*60 + VALUE(MID(A2,FIND(":",A2)+2,FIND("H",A2)-2))*60 + VALUE(LEFT(A2,FIND("M",A2)-2))

The position of the characters in the cells is not static – see the difference between A2 and A3.

Any help is very appreciated.

#### Attachments

• Screenshot 2021-01-05 151313.png
5.2 KB · Views: 6

### Excel Facts

Did you know Excel offers Filter by Selection?
Add the AutoFilter icon to the Quick Access Toolbar. Select a cell containing Apple, click AutoFilter, and you will get all rows with Apple

#### sandy666

##### Banned - Rules violations
maybe
 raw Minutes D : 13 H : 8 M 788 2 D : 2 H : 16 M 3016

Power Query:
``````// Table1
let
Source = Excel.CurrentWorkbook(){[Name="Table1"]}[Content],
TS = Table.AddColumn(Source, "Custom", each Text.Select([raw], {"0".."9",":"})),
Split = Table.SplitColumn(TS, "Custom", Splitter.SplitTextByEachDelimiter({":"}, QuoteStyle.Csv, false), {"Custom.1", "Custom.2"}),
TCC = Table.CombineColumns(Split,{"Custom.1", "Custom.2"},Combiner.CombineTextByDelimiter(".", QuoteStyle.None),"Merged"),
Trim = Table.AddColumn(TCC, "Minutes", each Text.Trim([Merged], ".")),
Suffix = Table.TransformColumns(Trim, {{"Minutes", each _ & ":00", type text}}),
Duration = Table.TransformColumnTypes(Suffix,{{"Minutes", type duration}}),
Minutes = Table.TransformColumns(Duration,{{"Minutes", Duration.TotalMinutes, type number}}),
TSC = Table.SelectColumns(Minutes,{"Minutes"})
in
TSC``````
would be better if you post representative example using not a picture

#### Saba Sabaratnam

##### Board Regular
You may try this method.

Enter the following formula in B1 BS and copy it down.

=IFERROR(IFERROR(MID(SUBSTITUTE(A1," ",""),1,FIND("D",SUBSTITUTE(A1," ",""))-1)*24*60,0)+IFERROR(MID(SUBSTITUTE(A1," ",""),FIND(":",SUBSTITUTE(A1," ",""))+1,FIND("H",SUBSTITUTE(A1," ",""))-1-FIND(":",SUBSTITUTE(A1," ","")))*60,0)+MID(SUBSTITUTE(A1," ",""),FIND("H",SUBSTITUTE(A1," ",""))+2,FIND("M",SUBSTITUTE(A1," ",""))-1-FIND("H",SUBSTITUTE(A1," ",""))-1),0)

Kind regards

Saba

#### jkerekgyarto

##### New Member
maybe
 raw Minutes D : 13 H : 8 M 788 2 D : 2 H : 16 M 3016

Power Query:
``````// Table1
let
Source = Excel.CurrentWorkbook(){[Name="Table1"]}[Content],
TS = Table.AddColumn(Source, "Custom", each Text.Select([raw], {"0".."9",":"})),
Split = Table.SplitColumn(TS, "Custom", Splitter.SplitTextByEachDelimiter({":"}, QuoteStyle.Csv, false), {"Custom.1", "Custom.2"}),
TCC = Table.CombineColumns(Split,{"Custom.1", "Custom.2"},Combiner.CombineTextByDelimiter(".", QuoteStyle.None),"Merged"),
Trim = Table.AddColumn(TCC, "Minutes", each Text.Trim([Merged], ".")),
Suffix = Table.TransformColumns(Trim, {{"Minutes", each _ & ":00", type text}}),
Duration = Table.TransformColumnTypes(Suffix,{{"Minutes", type duration}}),
Minutes = Table.TransformColumns(Duration,{{"Minutes", Duration.TotalMinutes, type number}}),
TSC = Table.SelectColumns(Minutes,{"Minutes"})
in
TSC``````
would be better if you post representative example using not a picture

LSOD Dashboard.xlsm
AB
1StatusTotal Minutes
2DOWN for 7 D : 13 H : 8 M#VALUE!
3Sector for 12 D : 2 H : 16 M
Sheet1
Cell Formulas
RangeFormula
B2B2=VALUE(LEFT(A2,FIND("D",A2)-2))*24*60 + VALUE(LEFT(A2,FIND("D",A2)-3))*24*60 + VALUE(MID(A2,FIND(":",A2)+2,FIND("H",A2)-2))*60 + VALUE(LEFT(A2,FIND("M",A2)-2))

does the words "down" and "sector" make difference? I am not sure how to implement your solution.

#### jkerekgyarto

##### New Member

You may try this method.

View attachment 29131

Enter the following formula in B1 BS and copy it down.

=IFERROR(IFERROR(MID(SUBSTITUTE(A1," ",""),1,FIND("D",SUBSTITUTE(A1," ",""))-1)*24*60,0)+IFERROR(MID(SUBSTITUTE(A1," ",""),FIND(":",SUBSTITUTE(A1," ",""))+1,FIND("H",SUBSTITUTE(A1," ",""))-1-FIND(":",SUBSTITUTE(A1," ","")))*60,0)+MID(SUBSTITUTE(A1," ",""),FIND("H",SUBSTITUTE(A1," ",""))+2,FIND("M",SUBSTITUTE(A1," ",""))-1-FIND("H",SUBSTITUTE(A1," ",""))-1),0)

Kind regards

Saba
I am new and didn't have the add-in installed - Here is the complete cell contents - Each cell will have various words like "DOWN" "Sector" "UP" - Does this make a difference to your solution?

LSOD Dashboard.xlsm
AB
1StatusTotal Minutes
2DOWN for 7 D : 13 H : 8 M#VALUE!
3Sector for 12 D : 2 H : 16 M
Sheet1
Cell Formulas
RangeFormula
B2B2=VALUE(LEFT(A2,FIND("D",A2)-2))*24*60 + VALUE(LEFT(A2,FIND("D",A2)-3))*24*60 + VALUE(MID(A2,FIND(":",A2)+2,FIND("H",A2)-2))*60 + VALUE(LEFT(A2,FIND("M",A2)-2))

#### jkerekgyarto

##### New Member
You may try this method.

View attachment 29131

Enter the following formula in B1 BS and copy it down.

=IFERROR(IFERROR(MID(SUBSTITUTE(A1," ",""),1,FIND("D",SUBSTITUTE(A1," ",""))-1)*24*60,0)+IFERROR(MID(SUBSTITUTE(A1," ",""),FIND(":",SUBSTITUTE(A1," ",""))+1,FIND("H",SUBSTITUTE(A1," ",""))-1-FIND(":",SUBSTITUTE(A1," ","")))*60,0)+MID(SUBSTITUTE(A1," ",""),FIND("H",SUBSTITUTE(A1," ",""))+2,FIND("M",SUBSTITUTE(A1," ",""))-1-FIND("H",SUBSTITUTE(A1," ",""))-1),0)

Kind regards

Saba
Saba - This formula is converting the hours and minutes but not the days - see below..

LSOD Dashboard.xlsm
AB
1StatusTotal Minutes
2DOWN for 7 D : 13 H : 8 M788
3Sector for 12 D : 2 H : 16 M136
Sheet1
Cell Formulas
RangeFormula
B2:B3B2=IFERROR(IFERROR(MID(SUBSTITUTE(A2," ",""),1,FIND("D",SUBSTITUTE(A2," ",""))-1)*24*60,0)+IFERROR(MID(SUBSTITUTE(A2," ",""),FIND(":",SUBSTITUTE(A2," ",""))+1,FIND("H",SUBSTITUTE(A2," ",""))-1-FIND(":",SUBSTITUTE(A2," ","")))*60,0)+MID(SUBSTITUTE(A2," ",""),FIND("H",SUBSTITUTE(A2," ",""))+2,FIND("M",SUBSTITUTE(A2," ",""))-1-FIND("H",SUBSTITUTE(A2," ",""))-1),0)

#### Saba Sabaratnam

##### Board Regular

I added a helper column to solve problem.

Enter the following formula in B1 and copy it down

=SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(A1," ",""),"Downfor",""),"Sectorfor","")

And enter the following formula in C1 and copy it down.

=IFERROR(IFERROR(MID(B1,1,FIND("D",B1,2)-1)*24*60,0)+IFERROR(MID(B1,FIND(":",B1)+1,FIND("H",B1)-1-FIND(":",B1))*60,0)+MID(B1,FIND("H",B1)+2,FIND("M",B1)-1-FIND("H",B1)-1),0)

Kind regards

Saba

#### Dave Patton

##### Well-known Member
Just a guess without a clear and useful example.

T202101a.xlsm
AB
1DataMinutes
2 D : 13 H : 8 M 788
3 2 D : 2 H : 16 M 3016
4 D : 2 H : 16 M 136
3b
Cell Formulas
RangeFormula
B2:B4B2=IF(ISNUMBER(--LEFT(A2,2)),LEFT(A2,2)*24*60+MID(A2,FIND(":",A2)+2,2)*60+MID(A2,FIND("M",A2)-3,2),MID(A2,FIND(":",A2)+2,2)*60+MID(A2,FIND("M",A2)-3,2))

#### jkerekgyarto

##### New Member
I added a helper column to solve problem.

View attachment 29133

Enter the following formula in B1 and copy it down

=SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(A1," ",""),"Downfor",""),"Sectorfor","")

And enter the following formula in C1 and copy it down.

=IFERROR(IFERROR(MID(B1,1,FIND("D",B1,2)-1)*24*60,0)+IFERROR(MID(B1,FIND(":",B1)+1,FIND("H",B1)-1-FIND(":",B1))*60,0)+MID(B1,FIND("H",B1)+2,FIND("M",B1)-1-FIND("H",B1)-1),0)

Kind regards

Saba
Thank you Saba! That works nicely!

#### sandy666

##### Banned - Rules violations
does the words "down" and "sector" make difference? I am not sure how to implement your solution.
no, it doesn't
 raw Minutes D : 13 H : 8 M 788 2 D : 2 H : 16 M 3016 10 D : 1 H : 45 M 14505 2 H 120 DOWN for 7 D : 13 H : 8 M 10868 Sector for 12 D : 2 H : 16 M 17416 Bla bla blabla 10 D : 1 H : 45 M blu blu Blublu 14505

on Data tab - New Query find and use Blank Query then on the ribbon of Power Query Editor go to Advanced Editor and replace code there with code from the post then OK, Close&Load

Replies
27
Views
316
Replies
10
Views
160
Replies
10
Views
323
Replies
4
Views
52
Replies
3
Views
532

1,130,218
Messages
5,640,953
Members
417,182
Latest member
mgcorreia

### 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.

### Which adblocker are you using?

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

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