Time conversion Question

crope1

New Member
Joined
Feb 4, 2021
Messages
5
Office Version
  1. 365
Platform
  1. Windows
I have a report to reports a duration in the following format. It is days/Hours/minutes/seconds as applicable. Is there a way to write a formula to convert these to seconds? Thanks!

17m 6s
1d 22h 56m
12s
 

Excel Facts

How to fill five years of quarters?
Type 1Q-2023 in a cell. Grab the fill handle and drag down or right. After 4Q-2023, Excel will jump to 1Q-2024. Dash can be any character.
Hi Crope1

Does this work for you?

Crope1.xlsx
AB
1TimeTime in Seconds
217m 6s1026
31d 22h 56m168960
412s12
Sheet1
Cell Formulas
RangeFormula
B2:B4B2=(IFERROR(LEFT(MID(" "&A2,SEARCH("d"," "&A2)-2,2),2)*86400,0))+(IFERROR(LEFT(MID(" "&A2,SEARCH("h"," "&A2)-2,2),2)*3600,0))+(IFERROR(LEFT(MID(" "&A2,SEARCH("m"," "&A2)-2,2),2)*60,0))+(IFERROR(LEFT(MID(" "&A2,SEARCH("s"," "&A2)-2,2),2),0))
 
Upvote 0
Solution
Hi Crope1

Does this work for you?

Crope1.xlsx
AB
1TimeTime in Seconds
217m 6s1026
31d 22h 56m168960
412s12
Sheet1
Cell Formulas
RangeFormula
B2:B4B2=(IFERROR(LEFT(MID(" "&A2,SEARCH("d"," "&A2)-2,2),2)*86400,0))+(IFERROR(LEFT(MID(" "&A2,SEARCH("h"," "&A2)-2,2),2)*3600,0))+(IFERROR(LEFT(MID(" "&A2,SEARCH("m"," "&A2)-2,2),2)*60,0))+(IFERROR(LEFT(MID(" "&A2,SEARCH("s"," "&A2)-2,2),2),0))
I believe so. If the data is in a different field, say G2, would I just need to change all A2 references in the formula to the corresponding data cell?
 
Upvote 0
Yes, like this

Crope1.xlsx
GH
1TimeTime in Seconds
217m 6s1026
31d 22h 56m168960
412s12
ColG
Cell Formulas
RangeFormula
H2:H4H2=(IFERROR(LEFT(MID(" "&G2,SEARCH("d"," "&G2)-2,2),2)*86400,0))+(IFERROR(LEFT(MID(" "&G2,SEARCH("h"," "&G2)-2,2),2)*3600,0))+(IFERROR(LEFT(MID(" "&G2,SEARCH("m"," "&G2)-2,2),2)*60,0))+(IFERROR(LEFT(MID(" "&G2,SEARCH("s"," "&G2)-2,2),2),0))
 
Upvote 0

Forum statistics

Threads
1,214,593
Messages
6,120,435
Members
448,961
Latest member
nzskater

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
Back
Top