For sum based on August in cell E8, select 8 instead of 7.
How this formula works
In the above example, the formula is:
(MONTH(A5:A11)=7) is the MONTH function and 7 is used to command Excel for selection of the month July,
B5:B11 contains the values that you want to sum, and,
A5:A11 are cells containing dates.