Set startDate and endDate.

Code refactoring.