# How to format date in ESSQL?

**URL:** <https://discuss.elastic.co/t/how-to-format-date-in-essql/187890>\
**Category:** Elasticsearch\
**Tags:** elastic-stack-sql\
**Created:** [June 27, 2019, 4:38pm UTC](https://discuss.elastic.co/t/how-to-format-date-in-essql/187890 "2019-06-27T16:38:51Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Facundo\_Chambo](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/facundo_chambo/32/48550_2.png) [@Facundo\_Chambo](https://discuss.elastic.co/u/Facundo_Chambo)\
**Post date:** [June 27, 2019, 4:38pm UTC](https://discuss.elastic.co/t/how-to-format-date-in-essql/187890/1 "2019-06-27T16:38:51Z")

</div>

I'm using ESSQL in Kibana Canvas to plot a line chart. I have a field **date** and want to group my data by "YEAR-MONTH".

My query is something like this:

```
SELECT date, duration FROM my_index GROUP BY date

```

but I need something like this:

```
SELECT DATE_FORMAT(date, 'YYYY-MM') as date, duration FROM my_index GROUP BY date

```

Is there any workaround to achieve this?

---

<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 25, 2019, 4:38pm UTC](https://discuss.elastic.co/t/how-to-format-date-in-essql/187890/2 "2019-07-25T16:38:56Z")

</div>

Closed on July 25, 2019, 4:38pm UTC

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