As an idea though I do not myself how to do it would be for the user to input a valid date based on the date format specified on the format of the date. If the user inputs an invalide date, the sub should either exit, or the user asked again until he puts the right date.