Fix the date calculation