# Count on a date field

**URL:** <https://discuss.elastic.co/t/count-on-a-date-field/184323>\
**Category:** Kibana\
**Created:** [June 5, 2019, 10:01am UTC](https://discuss.elastic.co/t/count-on-a-date-field/184323 "2019-06-05T10:01:12Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Thomas\_D](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/thomas_d/32/47351_2.png) [@Thomas\_D](https://discuss.elastic.co/u/Thomas_D)\
**Post date:** [June 5, 2019, 10:01am UTC](https://discuss.elastic.co/t/count-on-a-date-field/184323/1 "2019-06-05T10:01:12Z")

</div>

Hello,

Is it possible to count the number of documents for which a type date field corresponds to a specific date?

I need to know if an invoice has been paid, for that I put the date of payment on the date of default (1st of January 1970), how can I count the number of invoices that have a payment date to 1970?

Thanks in advance

---

<div class="post-metadata">

**Author:** ![thekm1](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/thekm1/32/35926_2.png) [@thekm1](https://discuss.elastic.co/u/thekm1)\
**Post date:** [June 5, 2019, 10:23am UTC](https://discuss.elastic.co/t/count-on-a-date-field/184323/2 "2019-06-05T10:23:02Z")

</div>

Hi @Thomas_D  
I have a suggestion:  
You could do a [date range filter](https://www.elastic.co/guide/en/elasticsearch/reference/7.0/query-dsl-range-query.html#_date_format_in_range_queries)

and take the value `hits.total.value` from the result.  
The api which can directly do this is called [\_count api](https://www.elastic.co/guide/en/elasticsearch/reference/current/search-count.html)

Let me know if this worked for you

---

<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:** [July 3, 2019, 10:23am UTC](https://discuss.elastic.co/t/count-on-a-date-field/184323/3 "2019-07-03T10:23:03Z")

</div>

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