# Custom date format on visualizations

**URL:** <https://discuss.elastic.co/t/custom-date-format-on-visualizations/223551>\
**Category:** Kibana\
**Created:** [March 13, 2020, 5:39pm UTC](https://discuss.elastic.co/t/custom-date-format-on-visualizations/223551 "2020-03-13T17:39:54Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![parosio](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/parosio/32/27367_2.png) [@parosio](https://discuss.elastic.co/u/parosio)\
**Post date:** [March 13, 2020, 5:39pm UTC](https://discuss.elastic.co/t/custom-date-format-on-visualizations/223551/1 "2020-03-13T17:39:55Z")

</div>

Hello,  
I' wondering if it's possible to have kibana (currently using 6.7.0 stack) to use the date format specified in "JSON Input"...

For example, in a Date Histogram X-Axis aggregation I could set:

```
  {
  "format": "E dd MMM YYYY"
  }

```

The request shows it:

```
  "aggs": {
    "2": {
      "date_histogram": {
        "field": "@timestamp",
        "interval": "1d",
        "time_zone": "Europe/Berlin",
        "format": "E dd MMM YYYY",
        "min_doc_count": 1
      },
      "aggs": {
        "1": {
          "sum": {
            "field": "Hit_Counter"
          }
        }
      }
    }
  }

```

and the response actually has the "key\_as\_string" correctly formatted:

```
 "aggregations": {
    "2": {
      "buckets": [
        {
          "1": {
            "value": 26153
          },
          "key_as_string": "Sat 01 Feb 2020",
          "key": 1580511600000,
          "doc_count": 41
        },
        {
          "1": {
            "value": 20099
          },
          "key_as_string": "Sun 02 Feb 2020",
          "key": 1580598000000,
          "doc_count": 48
        },

```

but the visualization keeps showing the format from the "Scaled date format" setting.

Is it possible to force Kibana to use the "key\_as\_string" values for the x-axis labels?

Regards,  
Paolo

---

<div class="post-metadata">

**Author:** ![Nathan\_Reese](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/nathan_reese/32/84829_2.png) [@Nathan\_Reese](https://discuss.elastic.co/u/Nathan_Reese)\
**Post date:** [March 13, 2020, 8:31pm UTC](https://discuss.elastic.co/t/custom-date-format-on-visualizations/223551/2 "2020-03-13T20:31:22Z")

</div>

It is not possible to format date values in the way you described.

Use [field formatters](https://www.elastic.co/guide/en/kibana/7.6/field-formatters-date.html) to format date fields

---

<div class="post-metadata">

**Author:** ![parosio](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/parosio/32/27367_2.png) [@parosio](https://discuss.elastic.co/u/parosio)\
**Post date:** [March 13, 2020, 10:34pm UTC](https://discuss.elastic.co/t/custom-date-format-on-visualizations/223551/3 "2020-03-13T22:34:19Z")

</div>

Thank you for the answer:

> [@Nathan\_Reese](#):
>
> Use [field formatters](https://www.elastic.co/guide/en/kibana/7.6/field-formatters-date.html) to format date fields

I didn't think to that possibility.

However, it seems not working for a DateHistogram aggregation:  
the DateFormat is not applied to the _bucket labels_, and they default to the `Scaled date format` global setting, so that only one format is allowed throughout the application.

The effect is shown in this image:

 ![image](https://us1.discourse-cdn.com/elastic/original/3X/b/0/b0b805c454db8c066d1003f004ea3b4fbcb3b415.png) the timestamp is correctly formatted in the second Metric column (Max @timestamp), but the bucket is labeled with a different format.

I've also tried the same with the flightData on [https://demo.elastic.co/](https://demo.elastic.co/), so it's not related to my kibana version.

It'd be nice to have the possibility to set a `Scaled date format` within an index pattern in kibana, and not only globally.

---

<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:** [April 10, 2020, 10:34pm UTC](https://discuss.elastic.co/t/custom-date-format-on-visualizations/223551/4 "2020-04-10T22:34:20Z")

</div>

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