英文:
Is there a TO_DATE() time equivalent function in Google Sheets ( something like TO_TIME() )?
问题
需要将文本格式的输入时间转换为整列的时间格式,我找到的唯一方法是使用来自此来源文章的TIME()和3个嵌套的MID(),使用DATE()也可以达到相同的效果:
=TIME(MID(K14,1,2),MID(K14,4,2),MID(K14,7,2))
使用DATE()的来源文章示例:
=DATE(RIGHT(A2,4),LEFT(A2,2),MID(A2,3,2))
在同一来源文章中,还展示了使用=TO_DATE(DATEVALUE(value))的示例:
=TIME(MID(K14,1,2),MID(K14,4,2),MID(K14,7,2))的方法效果很好,但考虑到TO_DATE(DATEVALUE(value))的"仅与日期相关的性质",我想知道是否有一种类似的方法,无需嵌套使用MID()就能实现。
我认为类似TO_TIME(TIMEVALUE(value))的方法应该是可用的,因为TIMEVALUE()相当于DATEVALUE(),但我没有找到它。
英文:
I need to convert a text formated input time to the time format with a formula on an entire column.
The only way I found to do it was with combining TIME() and 3 nested MID() from this source article doing the same with DATE() :
=TIME(MID(K14,1,2),MID(K14,4,2),MID(K14,7,2))
The source article example with DATE():
=DATE(RIGHT(A2,4),LEFT(A2,2),MID(A2,3,2))
Previoulsy in the same source article is shown this example with =TO_DATE(DATEVALUE(value)) :
The =TIME(MID(K14,1,2),MID(K14,4,2),MID(K14,7,2)) approach works well, but given the TO_DATE(DATEVALUE(value)) "date only related nature" I was wondering if some similar approach without the need to resort to nested MID() 's is possible.
I tought something like TO_TIME(TIMEVALUE(value)) with 'TO_TIME()' would be available since the TIMEVALUE() equivalent to the DATEVALUE() is supplied but I did not find it.
答案1
得分: 2
你可以简单地使用:
=--K14
然后将单元格格式设置为时间。你也可以直接将单元格 K14 格式设置为时间。
英文:
You can simply use:
=--K14
And then format the cell as time. You should also be able to format the cell K14 as time directly.
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。





评论