Google Sheets 中是否有类似 TO_TIME() 的 TO_DATE() 时间等效函数?

huangapple go评论72阅读模式
英文:

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))

Google Sheets 中是否有类似 TO_TIME() 的 TO_DATE() 时间等效函数?

使用DATE()的来源文章示例:

=DATE(RIGHT(A2,4),LEFT(A2,2),MID(A2,3,2))

Google Sheets 中是否有类似 TO_TIME() 的 TO_DATE() 时间等效函数?

在同一来源文章中,还展示了使用=TO_DATE(DATEVALUE(value))的示例:

Google Sheets 中是否有类似 TO_TIME() 的 TO_DATE() 时间等效函数?

=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))

Google Sheets 中是否有类似 TO_TIME() 的 TO_DATE() 时间等效函数?

The source article example with DATE():

=DATE(RIGHT(A2,4),LEFT(A2,2),MID(A2,3,2))

Google Sheets 中是否有类似 TO_TIME() 的 TO_DATE() 时间等效函数?

Previoulsy in the same source article is shown this example with =TO_DATE(DATEVALUE(value)) :

Google Sheets 中是否有类似 TO_TIME() 的 TO_DATE() 时间等效函数?

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.

huangapple
  • 本文由 发表于 2023年7月23日 23:11:25
  • 转载请务必保留本文链接:https://go.coder-hub.com/76748966.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定