首页 > 解决方案 > 在另一个时间之前/之后找到最近的时间

问题描述

我有一个不一定精确到指定时间的时间数据库。例如,如果我想选择 12:00 PM 并且我的列在 A 列中有时间:

[9:00 AM, 11:55 AM, 2:00 PM, 6:00 PM],

最接近的时间是 11:上午 55 点,最晚是下午 2:00。我对代码的尝试:

=MAXIF(A:A, A:A, 12:00)
=MINIF(A:A, A:A, 12:00)

但无济于事,有什么想法吗?

标签: filtergoogle-sheets

解决方案


You want the max where the time is less than or equal to the criteria and the Min for the time greater than or equal to the criteria:

=MAXIFS(A:A, A:A,"<=12:00")
=MINIFS(A:A, A:A,">=12:00")

enter image description here


推荐阅读