Date-based sorting and input validation