Google Sheets =MONTH works but MONTH in QUERY does not - google-sheets

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?

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)

Related

Google Sheets Date Formula

I have a personal finances Google Sheet with all my expenditures (column A) and corresponding dates (column B) of the month when they are due to be paid.
I would like to create a formula that shows me what is left for the remainder of the month depending on what day of the month I am looking at the sheet.
Something like, ifDate is today, sum all remaining dates of the month expenses.
TIA
Use this formula it works even if the dates is disordered.
=SUMIF(C2:C,">"&F2,B2:B)
Update
=SUMIF(D3:D,">"&TODAY(),C3:C)

Sum range by month in Google Sheets with date conditional

I have a sheet with these columns:
A (Date): Range of dates for the year
B (Amount): An amount for an expense
D (Month): Name of each month in the year (e.g. June, July, etc)
I've tried this as suggested to work in other posts:
=SUMPRODUCT(B:B, ISDATE(A:A)*MONTH(A:A)=MONTH(D3&1))
I get the error Function MONTH parameter 1 expects number values. But 'Date' is a text and cannot be coerced to a number. with this.
If I remove the header, I just get a 0 for the sum for each month, which is incorrect.
How do I get this to work for each month the way my sheet is setup?
What the sheet currently looks like:
https://docs.google.com/spreadsheets/d/1_8DQTa9aXGjvd7twL6RZMcFyqxa4Sg7eVTcD2wDXH2A/edit?usp=sharing
Try this instead. Not sure where you got that other formula:
=SUMPRODUCT(B:B,TEXT(A:A,"mmmm")=D3)
use:
=ARRAYFORMULA(IFNA(VLOOKUP(MONTH(D3:D10&1),
QUERY(A2:B, "select month(A)+1,sum(B) group by month(A)"), 2, )))
Use this
=IF(D3="",,IFERROR(SUM(FILTER($B$2:$B,MONTH($A$2:$A&1)=MONTH(D3&1))),""))

How to Take month number in select statement in google Query

How to take the current month number in the Select query in google sheets?
I am writing a query like this wherein Col21 I have month numbers like 1,2,3 4, etc based on month
=QUERY({Sheet1!A:X},"Select Col7,Col13 where Col21= '&month(today())&' ")
It is giving me headers only
whereas when I am writing a query like this :
=QUERY({Sheet1!A:X},"Select Col7,Col13 where Col21 contains '8' ")
It is giving me all records, but I want to replace the static value of month by Current month number only; what should I do for this so that when month changes I don't have to do any changes in the query.
Please make sure Col21 is in number, not in string
=QUERY({Sheet1!A:X},"Select Col7,Col13 where Col21= "&month(today()))

Is there a query formula in spreadsheets where if the date in the column matches todays date, it pulls the values from the rows within that column?

In the picture M3 is today's date. Is there a formula that will automatically pull data from M8 (same column) since M3's date matches today and place it in another, unrelated cell? The closest I can get is a where function with a query, but I could not get it to work.
use:
=INDIRECT(ADDRESS(8, MATCH(TODAY(), 3:3, 0)))

Count Number of Each Month in Column of dates in Google Spreadsheet

I have a Google sheet with a column of dates. I would like to get a total for each month, so that I can see how many of the dates are January, February, March, etc. This formula does not work (Dates is the name of range):
=COUNTIF(Dates,Month=1)
Any help is appreciated.
Following the logic of your proposition, the error is that MONTH() returns an integer, not an array. You can add ARRAYFORMULA() to do the job :
=COUNTIF( ARRAYFORMULA( MONTH( Dates ) ), "=2" )
I finally devised the correct search term for Google help
=sumproduct(month(Dates)=2)

Resources