Google表格= MONTH有效,但QUERY中的MONTH无效 [英] Google Sheets =MONTH works but MONTH in QUERY does not

查看:92
本文介绍了Google表格= MONTH有效,但QUERY中的MONTH无效的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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 function MONTH on a column that is not a DATE or a DATETIME 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屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆