Reputation: 73
I am trying to convert a duration to a number. I have a cell that lists total hours and total minutes from a Google Meet. I am trying to automatically convert that information to the total number of minutes expressed as a number.
Ex: Cell 1(1 hr 8 min) to Cell 2 (68)
The google meet data, with the total hour/ total minutes) will be automatically pasted in from the meet report.
Is this possible?
Upvotes: 0
Views: 462
Reputation: 9345
Supposing your original string were in A2, and that no meeting ran more than 9 hr 59 min, you could use this simple approach:
=TIME(LEFT(A2,1),MID(A2,6,2),0)*24*60
ADDENDUM (after more information added by poster)
This will cover your newly given scenarios:
=TIME(IFERROR(REGEXEXTRACT(A2,"(\d+) hr"),0),REGEXEXTRACT(A2,"(\d+) min"),0)*24*60
Upvotes: 0
Reputation: 1055
If you have the duration always expressed as X hr Y min
,
UPDATED:
= ARRAYFORMULA(
IFNA(
IF(LEN(B2:B),
REGEXEXTRACT(B2:B, "\d+") * 60 + REGEXEXTRACT(B2:B, "\D+(.+)min"),
""),
REGEXEXTRACT(B2:B, "\d+")
)
)
This part extracts the number before the hr
and we multiply it by 60
REGEXEXTRACT(B2:B, "\d+")*60
This part extracts the number between hr
and min
and we add it to the above result:
REGEXEXTRACT(B2:B, "\D+(.+)min")
To adapt the formula to your situation, please consider the following notes:
Upvotes: 3