Google-sheets – How to calculate a sum based on a date range

formulasgoogle sheets

I am trying to find dates within 30 days in Column B. If the date matches the range it should sum all those that match in column I.

I have tried this formula:

=SUMIF(B:B,">="&TODAY()-30,I:I)

It won't work in Google Sheets. I tried moving the date outside but that didn't work either.

Best Answer

You should use the DATEVALUE function:

=SUMIF(B:B,">"&DATEVALUE(TODAY()-30),I:I)

Calculate Sum Based On Date Range in Google Sheets

As an alternative you could place the date =(TODAY()-30) in a cell (eg cell C1) and use the formula

=SUMIF(B:B,">"&C1,I:I)

SUMIF with criterion a date range from a cell

Functions used: