Added function to compare dates