Google Sheets =MONTH works but MONTH in QUERY does not

筅森魡賤 提交于 2020-05-28 11:54:05

问题


Google Sheets: I checked my column of dates is in DATE format not Automatic.

When I use MONTH in a cell I get the correct month back from that column.

When I do a QUERY such as =query('Main'!A1:M20,"select MONTH(M)",1) I get #VALUE! with the comment:

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

Why does QUERY not see the column as being in DATE format but =MONTH does?


回答1:


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) 



来源:https://stackoverflow.com/questions/54878095/google-sheets-month-works-but-month-in-query-does-not

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!