【问题标题】:Counting when one date is less than another date in Google Sheets在 Google 表格中计算一个日期小于另一个日期的时间
【发布时间】:2021-01-11 04:13:25
【问题描述】:

在 Google 表格中,当 B 列(实际)中的日期小于 A 列(预期)中的日期时,我想计算日期值的数量

我想在单个单元格中显示预期>实际时的日期总数。 我相信 Google 表格中的公式看起来像这样,但我无法让它发挥作用。

=COUNTIF('Sheet1'!A1:A500,">"&'Sheet1'!B1:B500)

【问题讨论】:

    标签: google-sheets formula google-sheets-formula countif


    【解决方案1】:

    确保您比较的是日期对象,而不是看起来像日期的文本。要检查一个值是否为日期,请执行以下操作:

    =isdate(A1) //  returns true if the value in A1 is an actual date
    

    通常,您可以将文本转换为日期:

    试试to_date

    =COUNTIF(arrayformula(to_date(Sheet1!A1:A500)),">"&to_date(Sheet1!B1:B500))
    

    datevalue:

    =COUNTIF(arrayformula(DATEVALUE(Sheet1!A1:A500)),">"&DATEVALUE(Sheet1!B1:B500))
    

    【讨论】:

      【解决方案2】:

      请注意,日期实际上是数字。
      所以像September/23/2020这样的日期和44086 是一样的

      除了马里奥斯正确答案,还可以使用查询公式

      =QUERY(Sheet1!A1:B,"select count(B) where A>B")

      如果你只想得到省略标题的结果,你可以使用

      =QUERY(Sheet1!A1:B,"select count(B) where A>B label count(B) '' ")
      

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 2013-06-24
        • 1970-01-01
        • 2015-11-07
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2021-06-14
        相关资源
        最近更新 更多