# Min\_bucket date format does not work

**URL:** <https://discuss.elastic.co/t/min-bucket-date-format-does-not-work/159052>\
**Category:** Elasticsearch\
**Created:** [December 2, 2018, 4:10pm UTC](https://discuss.elastic.co/t/min-bucket-date-format-does-not-work/159052 "2018-12-02T16:10:38Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![gabor.toth](https://avatars.discourse-cdn.com/v4/letter/g/7ea924/32.png) [@gabor.toth](https://discuss.elastic.co/u/gabor.toth)\
**Post date:** [December 2, 2018, 4:10pm UTC](https://discuss.elastic.co/t/min-bucket-date-format-does-not-work/159052/1 "2018-12-02T16:10:38Z")

</div>

Hi,

I am trying to format of a result of a min\_bucket. (I want to get the minimum of maximum date by datasource, which is working well.)

```
GET my-index/_search
{
  "size": 0,
  
  "aggs": {
    "source": {
      "terms": {
        "field": "datasource",
        "size": 10
      },
      "aggs": {
        
        "maxdate": {
          
          "max": {
            "field": "my-timestamp",
            "format": "yyyy-MM-dd"
          }
        }
      }
      
    }
    ,
    
    "min_datez": {
      
      "min_bucket": {

        "buckets_path": "source>maxdate",
        "format": "date_time"
      }
    }
  }
}

```

Result:

```
...
"min_datez": {
      "value": 1533074400000,
      "value_as_string": "date_time1533074400000",
      "keys": [
        "some-key-1"
      ]
    }

```

I think formatting of "value\_as\_string" is wrong. How should I do date formatting in this case?

---

<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:** [December 30, 2018, 4:10pm UTC](https://discuss.elastic.co/t/min-bucket-date-format-does-not-work/159052/2 "2018-12-30T16:10:39Z")

</div>

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