function to check date