在电子表格中使用带有日期时间单元格的查询

Using a query with a datetime cell in spreadsheets

我需要查询一个包含日期时间的单元格,但在导入时默认格式化为仅显示日期。

31/7/2020 19:18:58 (in reality it's like this)

31/7/2020 (but it shows this)

所以当我 运行 这个查询时:

=QUERY(A5:R10, "select K")

它returns无论我做什么都只有日期:

31/07/2020

我试过:

问题是:

有没有办法做我想做的事情而不用重新格式化导入的单元格?

link 测试一下: https://docs.google.com/spreadsheets/d/14rGPngGvFXGP8txMS2yFo1v4gPcI4K1oYWj_8yt2Uq8/edit?usp=sharing

当我用 F2 select 一个单元格时,它显示时间:

非常感谢您的宝贵时间!

select B 列并将其格式化为日期时间


或不重新格式化:

=ARRAYFORMULA(QUERY(1*(B2:B4&""), "format Col1 'yyyy-mm-dd hh:mm:ss'"))

或:

=ARRAYFORMULA(QUERY(TEXT(B2:B4, "yyy-mm-dd hh:mm:ss"), "select *"))

只需确保您的单元格格式为 Automatic

如果没有,即使你使用查询的format子句,该子句也会被忽略