# CountIF cells related to a date range (month)

I have a real estate company and have a spreadsheet that tabulates all the data on our closed deals. One column is the date that the property closed. I am trying to figure out a formula that automatically counts the cells(closed deals) from the closed date column that will then put that number in a summary column of deals closed each month.

Thinking `COUNTIF(d1:d24,>01/01/22,<01/30/22)` for the month of January.

Any help would be greatly appreciated.

Instead of using countif, try countifs (with the s at the end):

``````=COUNTIFS(D1:D24,">=01/01/2022",D1:D24,"<=30/01/2022")
``````

If it doesn't work, show (share or make a similar sample) your spreadsheet. Visualizing it makes it easier to help...

Just to show that Google Sheets often provides more than one way of getting an outcome, try this `query`.

`=query({D2:D24},"select count(Col1) where Col1 >= date '2022-01-01' and Col1 <= date '2022-01-30' label Count(Col1) ''")`

SAMPLE Rather than hardcoding dates into formula, use a dynamic formula and reference date cells.

Query

• `=query(A1:D8,"select count(D) where D is not null and D >= date '"&TEXT(G8,"yyyy-mm-dd")&"' and D <= date '"&TEXT(G9,"yyyy-mm-dd")&"' label count(D) ''")`

Countifs

• `=countifs(\$D\$2:\$D,">="&\$G\$3,\$D\$2:\$D,"<="&\$G\$4)` 