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