如果在特定日期之前,用文本替换返回查询中的日期

Replace date in returned query with text if before a certain date

我有一份报告,其格式必须更改、删除多个列、按类别过滤等。

G 列是日期 'YYYY-MM-DD' 列,出于我的目的,如果日期早于今天,我需要将日期单元格更改为字符串 'OOD' 但是我似乎无法弄清楚我应该如何尝试这个。

我尝试了数组公式和替代等的各种组合,但似乎都无法解决查询问题。

=QUERY('test data'!1:994,"select C,G,J,K,O where F='FOOD' and C is not null order by K asc",0)

这样试试:

=ARRAYFORMULA(QUERY({'test data'!A1:F994, 
 IF('test data'!G1:G994<TODAY(), "OOD", 'test data'!G1:G994), 'test data'!H1:994}, 
 "select Col3,Col7,Col10,Col11,Col15 
  where Col6='FOOD' 
    and Col3 is not null 
  order by Col11", 0))