How to add a counter based on dates