Google表格= MONTH有效,但QUERY中的MONTH无效 [英] Google Sheets =MONTH works but MONTH in QUERY does not
问题描述
Google表格:我检查了日期列是否为 DATE
格式,而不是 Automatic
。
Google Sheets: I checked my column of dates is in DATE
format not Automatic
.
当我在单元格中使用 MONTH
时,我会从该列中获得正确的月份。
When I use MONTH
in a cell I get the correct month back from that column.
当我执行 QUERY
时,例如 = query('Main'!A1:M20, select MONTH(M), 1)
我得到 #VALUE!
的注释:
When I do a QUERY
such as =query('Main'!A1:M20,"select MONTH(M)",1)
I get #VALUE!
with the comment:
无法解析参数2的函数
QUERY
:无法在具有以下功能的列上执行函数MONTH
:不是DATE
或DATETIME
列
Unable to parse the Function
QUERY
for parameter 2: Can't perform the functionMONTH
on a column that is not aDATE
or aDATETIME
column
为什么 QUERY
看不到列为 DATE
格式,而是 = MONTH
是吗?
Why does QUERY
not see the column as being in DATE
format but =MONTH
does?
推荐答案
在查询中的月份是从0开始编号的,因此,则需要添加+1以获取第一个月,然后执行一个奇怪的逻辑: where month1 = month2以获取二月( month(A)+ 1 = 3
三月, month(A)+ 1 = 12
12月等)
months in a query are numbered and starts from 0, therefore, you will need to add +1 to get the first month and then do a weird logic: "where month1=month2" to get february (month(A)+1=3
for march, month(A)+1=12
for december, etc.)
=QUERY(A1:D10, "select A,B,C,D where month(A)+1=2", 1)
这篇关于Google表格= MONTH有效,但QUERY中的MONTH无效的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!