added the compareDate function.