[英]Convert Time string into hours using Excel formula
I have the following format of data in Excel. 我在Excel中具有以下数据格式。
1 hour
5 hours
30 mins
2 hours 30 mins
1 hour 45 mins
I would like to convert this to the following 我想将其转换为以下内容
1
5
0.5
2.5
1.75
Can someone help with this? 有人可以帮忙吗?
If you only have hours and minutes, a few substitutions should do the trick: 如果您只有几个小时和几分钟,那么应该做一些替换:
=(IF(ISERROR(FIND("hour",A1)),"00:","")&SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(A1,"s","")," hour", ":00"),":00 ",":")," min",""))*24
Remove the extra s
first, then substitute the hour
by :00
, then substitute :00
with nothing to 'stick' the hours and minutes together, finally remove the min
. 首先删除多余的
s
,然后将hour
替换为:00
,然后用:00
替换为:00
,以将小时和分钟“粘在一起”,最后删除min
。
If there is no hour
in the text, prepend 00:
and multiply the whole thing by 24 to convert the time into hours. 如果文本中没有
hour
,请在前面加上00:
并将整个内容乘以24,以将时间转换为小时。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.