How to add conditions to the date?