Convert text of 0h 0m 0s to actual time data....

coolkev99

New Member
Joined
Jul 6, 2020
Messages
6
Office Version
  1. 365
Platform
  1. Windows
Hi all, I have a two fold challenge I'm trying to solve, and I would greatly prefer not to have to use VBA script/macro...

Challenge #1) I get time data sent daily (example: 1h 8m 3s). Yes, the time data has text with the "h" "m" and "s", but only if applicable. The goal is to try to get this data down to minutes ONLY. The problem is, if the time is less that an hour it will not have the "h".(Example 8m 3s), and again, if the time data is less than a minute the time data will only have the time in seconds only. So for example it would NOT be sent like "0h 0m 8s", it would just be "8s". I originally attempted to use the following formula "=ROUNDDOWN(TIMEVALUE(SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(A1,"h",":"),"m",":"),"s",""))*1440,0)" But like I mentioned, this only works if all elements of "h" "m" and "s" are there. Just to make it even more weird, if the time data is like 1 hour flat, it WILL have the "m" and the "s" appearing. (example 1h 0m 0s)

Challenge #2) The time data I get is every half-hour, but I would like to have excel (if possible) find the highest time reported within that hour period (or pair).

So for example if:
1pm-1:30pm = 1h 10m 55s
1:30pm-2pm = 35m 0s

Then excel would compare these and report in another cell in rounded down minutes:
1pm-2pm = 70

PLEASE see image as it provides a better example of what I'm trying to build/how I'd like it to look.

TimeCalc.jpg
 

Excel Facts

Difference between two dates
Secret function! Use =DATEDIF(A2,B2,"Y")&" years"&=DATEDIF(A2,B2,"YM")&" months"&=DATEDIF(A2,B2,"MD")&" days"
Roykana.xlsb
AB
11h 6m 20s01:06:20
Blad1
Cell Formulas
RangeFormula
B1B1=TIME(IFERROR(MID("00"&A1,SEARCH("h","00"&A1)-2,2),0),IFERROR(MID("00"&A1,SEARCH("m","00"&A1)-2,2),0),IFERROR(MID("00"&A1,SEARCH("s","00"&A1)-2,2),0))
 
Upvote 0
Solution
the 2nd table is 50 rows !
Roykana.xlsb
ABCDEFGH
1timetime2time reportedstarthighesthour max
21h 6m 20s01:06:2000:05:00 00:07:0000:07:00
36m 20s00:06:2000:06:0000:30 -
420s00:00:2000:07:0001:0000:08:0000:08:00
51h01:00:0000:08:0001:30 -
6 02:00  
7 02:30 -
803:00  
Blad1
Cell Formulas
RangeFormula
E2:E8E2=TIME(0,(ROW()-ROW($E$1)-1)*30,0)
F2:F8F2=MAXIFS(Tabel3[time reported],Tabel3[time2],">="&[@start],Tabel3[time2],"<"&E3)
G2:G8G2=IF(MINUTE([@start])=0,MAX(F2:F3),"-")
B2:B7B2=TIME(IFERROR(MID("00"&A2,SEARCH("h","00"&A2)-2,2),0),IFERROR(MID("00"&A2,SEARCH("m","00"&A2)-2,2),0),IFERROR(MID("00"&A2,SEARCH("s","00"&A2)-2,2),0))
 
Upvote 0
THANKS! The formula for the first challenge works perfect. I think maybe I didn't explain my second challenge well as I didn't understand the solution to that one. But I figured it out using MAX function. I also added a check so it would report "no data" if both cells were empty.

Formula below would compare two time entries in row (A1 and A2) time and provide higher result rounded down to nearest minute:

=IF(AND(A1="",A2=""),"no data",MAX(ROUNDDOWN(TIME(IFERROR(MID("00"&A1,SEARCH("h","00"&A1)-2,2),0),IFERROR(MID("00"&A1,SEARCH("m","00"&A1)-2,2),0),IFERROR(MID("00"&A1,SEARCH("s","00"&A1)-2,2),0))*60*24,0),(ROUNDDOWN(TIME(IFERROR(MID("00"&A2,SEARCH("h","00"&A2)-2,2),0),IFERROR(MID("00"&A2,SEARCH("m","00"&A2)-2,2),0),IFERROR(MID("00"&A2,SEARCH("s","00"&A2)-2,2),0))*60*24,0))))
 
Upvote 0

Forum statistics

Threads
1,214,653
Messages
6,120,749
Members
448,989
Latest member
mariah3

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