# Finding unique dates

**URL:** <https://discuss.elastic.co/t/finding-unique-dates/287489>\
**Category:** Elasticsearch\
**Created:** [October 23, 2021, 12:54pm UTC](https://discuss.elastic.co/t/finding-unique-dates/287489 "2021-10-23T12:54:10Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![cassebas](https://avatars.discourse-cdn.com/v4/letter/c/d9b06d/32.png) [@cassebas](https://discuss.elastic.co/u/cassebas)\
**Post date:** [October 23, 2021, 12:54pm UTC](https://discuss.elastic.co/t/finding-unique-dates/287489/1 "2021-10-23T12:54:10Z")

</div>

I have a dataset about deliveries, with a datetime in the format yyyy-mm-dd hh:mm:ss (for example: "29-2-2020 13:31:00"). Now I wan't to count the number of unique days in the set. I tried using cardinality in combination with a 'format': "yyyy-MM-dd", but this is not working. Can someone tell me how to get just the days?

This is what I have so far

search\_body = {  
'aggs': {  
'type\_count': {  
'cardinality': {  
'field': 'dropoff\_datetime'  
}  
}  
}  
}

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/elastic/original/3X/1/a/1ac57faf039f6b580b3f104ef42a2a89e41014de.png) [@system](https://discuss.elastic.co/u/system)\
**Post date:** [November 20, 2021, 12:54pm UTC](https://discuss.elastic.co/t/finding-unique-dates/287489/2 "2021-11-20T12:54:21Z")

</div>

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.
