# Canvas ESSQL current date - 30 days query

**URL:** <https://discuss.elastic.co/t/canvas-essql-current-date-30-days-query/193486>\
**Category:** Kibana\
**Created:** [August 2, 2019, 8:46am UTC](https://discuss.elastic.co/t/canvas-essql-current-date-30-days-query/193486 "2019-08-02T08:46:57Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![samgs](https://avatars.discourse-cdn.com/v4/letter/s/71c47a/32.png) [@samgs](https://discuss.elastic.co/u/samgs)\
**Post date:** [August 2, 2019, 8:46am UTC](https://discuss.elastic.co/t/canvas-essql-current-date-30-days-query/193486/1 "2019-08-02T08:46:58Z")

</div>

Hello! I'm trying to make a relative date query in elasticsearch SQL. I have this code:

`SELECT * FROM index WHERE date > CURRENT_DATE - INTERVAL '30' DAY`

Which seems to be correct. However when I run it, it gives the following error:

`[essql] > Unexpected error from Elasticsearch: [parse_exception] failed to parse date field [2019-07-02T00:00Z] with format [HH:mm yyyy-MM-dd]: [Text '2019-07-02T00:00Z' could not be parsed at index 2]`

Can you please help me understand this. Is there a way to reformat the date format output by 'CURRENT\_DATE'? Do I need to reformatting the way I store my dates in elasticsearch?

This is driving me up the wall. Any help is hugely appreciated.  
Thanks

---

<div class="post-metadata">

**Author:** ![Andrei\_Stefan](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/andrei_stefan/32/47533_2.png) [@Andrei\_Stefan](https://discuss.elastic.co/u/Andrei_Stefan)\
**Post date:** [August 2, 2019, 10:47am UTC](https://discuss.elastic.co/t/canvas-essql-current-date-30-days-query/193486/2 "2019-08-02T10:47:57Z")

</div>

@samgs you are right and thank you for posting your question. This is a bug. We do not set a specific format in the `range` filter we create and, implicitly, Elasticsearch takes the format of the date constant we pass in resulting from the `CURRENT_DATE - INTERVAL '30' DAY` calculus. And that format is `yyyy-MM-dd'T'HH:mm:ss.SSSV`.

I've created an issue and I'll take care of it: [https://github.com/elastic/elasticsearch/issues/45139](https://github.com/elastic/elasticsearch/issues/45139).

I don't think there is any workaround at the moment other than using the default format for your `date` fields.

---

<div class="post-metadata">

**Author:** ![stefws](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/stefws/32/6442_2.png) [@stefws](https://discuss.elastic.co/u/stefws)\
**Post date:** [August 22, 2019, 1:32pm UTC](https://discuss.elastic.co/t/canvas-essql-current-date-30-days-query/193486/3 "2019-08-22T13:32:27Z")

</div>

Where might we find doc on ES SQL and more specifically what functions have been implemented in what version and howto use them?

---

<div class="post-metadata">

**Author:** ![Andrei\_Stefan](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/andrei_stefan/32/47533_2.png) [@Andrei\_Stefan](https://discuss.elastic.co/u/Andrei_Stefan)\
**Post date:** [August 23, 2019, 7:03am UTC](https://discuss.elastic.co/t/canvas-essql-current-date-30-days-query/193486/4 "2019-08-23T07:03:06Z")

</div>

@stefws this is our main page for the list of functions available in ES SQL: [https://www.elastic.co/guide/en/elasticsearch/reference/7.x/sql-functions.html](https://www.elastic.co/guide/en/elasticsearch/reference/7.x/sql-functions.html)

Regarding the specific versions, you'd have to look for the release notes of those versions. It might also help the github issues created for features/bugs, where the associated PR that implemented/fixed the feature/bug has version labels.

---

<div class="post-metadata">

**Author:** ![stefws](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/stefws/32/6442_2.png) [@stefws](https://discuss.elastic.co/u/stefws)\
**Post date:** [August 23, 2019, 12:14pm UTC](https://discuss.elastic.co/t/canvas-essql-current-date-30-days-query/193486/5 "2019-08-23T12:14:21Z")

</div>

@Andrei_Stefan Thanks for the pointer 🙂

---

<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:** [September 20, 2019, 12:14pm UTC](https://discuss.elastic.co/t/canvas-essql-current-date-30-days-query/193486/6 "2019-09-20T12:14:28Z")

</div>

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