AGGREGATE was built to handle messy data from the start.
Excel already knows when the month ends.