In Google Sheets how do I convert a string containing a date and a time in a sortable date format with a formula?

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

In Google Sheets how do I convert a string containing a date and a time in a sortable date format with a formula?

问题

我有一列单元格,其中包含日期,日期都是以"YYYY-MM-DD HH.mm"格式显示的。我想使用公式将它们转换为可以通过GSheets的SORT()函数进行排序的格式,而不是使用脚本。我尝试了DATE函数,但只能将日期转换,而没有时间。是否有可能实现这个目标?

英文:

I have a column of cells containing dates, all in the format "YYYY-MM-DD HH.mm", I would like to convert them to a format that is then sortable by the SORT() function of GSheets, using a formula and not scripts. I tried DATE but I can only convert the date without the time. Is this possible to do?

答案1

得分: 2

你可以使用以下公式:

=date(left(A1,4),mid(A1,6,2),mid(A1,9,2))+time(mid(A1,12,2),mid(A1,15,2),0)

英文:

You can use the following formula:

=date(left(A1,4),mid(A1,6,2),mid(A1,9,2))+time(mid(A1,12,2),mid(A1,15,2),0)

答案2

得分: 1

你也可以使用DATEVALUETIMEVALUE函数:求和将返回结果。

=DATEVALUE(A1)+TIMEVALUE(A1)

然后,相应地格式化单元格,以显示日期而不是数字。

英文:

You can use DATEVALUE and TIMEVALUE too: the sum will return the result.

=DATEVALUE(A1)+TIMEVALUE(A1)

Then, format the cell accordingly so it displays the date instead of the number

huangapple
  • 本文由 发表于 2023年2月14日 20:50:12
  • 转载请务必保留本文链接:https://go.coder-hub.com/75448091.html
匿名

发表评论

匿名网友

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

确定