refactor date select logic