# Elasticsearch SQL query with date and timestamp

**URL:** <https://discuss.elastic.co/t/elasticsearch-sql-query-with-date-and-timestamp/307753>\
**Category:** Kibana\
**Created:** [June 21, 2022, 10:40am UTC](https://discuss.elastic.co/t/elasticsearch-sql-query-with-date-and-timestamp/307753 "2022-06-21T10:40:09Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![Pranjal\_Sett](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/pranjal_sett/32/98834_2.png) [@Pranjal\_Sett](https://discuss.elastic.co/u/Pranjal_Sett)\
**Post date:** [June 21, 2022, 10:40am UTC](https://discuss.elastic.co/t/elasticsearch-sql-query-with-date-and-timestamp/307753/1 "2022-06-21T10:40:09Z")

</div>

Hi,

As per specification I want to get the data as per logic given.

Here is the logic below:  
sum(QUANTITY) where FILE\_CREATION\_DATE = TODAY() and INDEX\_NUMBER in (2, 4) and SUBINVENTORY = [x,y,z]

I have transferred this to like this below:  
SELECT sum(QUANTITY) FROM "dos-file-\*" where INDEX\_NUMBER.keyword in (2,4) and SUBINVENTORY.keyword in ('X') and FILE\_CREATION\_DATE=CURRENT\_DATE

If I run this query without this "FILE\_CREATION\_DATE=CURRENT\_DATE", it is running fine. and gives me the SUM..

But If I run this query with this "FILE\_CREATION\_DATE=CURRENT\_DATE" , it is does not giving me and output it is showing as null.

I just want to compare with Today's date with FILE\_CREATION\_DATE, it is not happening.

Format of this attribute like below:  
FILE\_CREATION\_DATE : Jun 21, 2022 @ 14:53:22.000

How can I achieve this ?

---

<div class="post-metadata">

**Author:** ![Pranjal\_Sett](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/pranjal_sett/32/98834_2.png) [@Pranjal\_Sett](https://discuss.elastic.co/u/Pranjal_Sett)\
**Post date:** [June 21, 2022, 12:24pm UTC](https://discuss.elastic.co/t/elasticsearch-sql-query-with-date-and-timestamp/307753/2 "2022-06-21T12:24:38Z")

</div>

Can anyone help on this please?

---

<div class="post-metadata">

**Author:** ![Pranjal\_Sett](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/pranjal_sett/32/98834_2.png) [@Pranjal\_Sett](https://discuss.elastic.co/u/Pranjal_Sett)\
**Post date:** [June 22, 2022, 6:21am UTC](https://discuss.elastic.co/t/elasticsearch-sql-query-with-date-and-timestamp/307753/3 "2022-06-22T06:21:59Z")

</div>

@stephenb .. I am little bit stuck here. Can you please help me on that?

---

<div class="post-metadata">

**Author:** ![Pranjal\_Sett](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/pranjal_sett/32/98834_2.png) [@Pranjal\_Sett](https://discuss.elastic.co/u/Pranjal_Sett)\
**Post date:** [June 22, 2022, 11:47am UTC](https://discuss.elastic.co/t/elasticsearch-sql-query-with-date-and-timestamp/307753/4 "2022-06-22T11:47:26Z")

</div>

Ok. Resolved. I was making logical mistake.

---

<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 20, 2022, 11:47am UTC](https://discuss.elastic.co/t/elasticsearch-sql-query-with-date-and-timestamp/307753/5 "2022-07-20T11:47:53Z")

</div>

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