# Convert Date to Human readable form

**URL:** <https://discuss.elastic.co/t/convert-date-to-human-readable-form/188305>\
**Category:** Elasticsearch\
**Created:** [July 1, 2019, 12:00pm UTC](https://discuss.elastic.co/t/convert-date-to-human-readable-form/188305 "2019-07-01T12:00:05Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![mkhayyam\_q](https://avatars.discourse-cdn.com/v4/letter/m/bb73d2/32.png) [@mkhayyam\_q](https://discuss.elastic.co/u/mkhayyam_q)\
**Post date:** [July 1, 2019, 12:00pm UTC](https://discuss.elastic.co/t/convert-date-to-human-readable-form/188305/1 "2019-07-01T12:00:05Z")

</div>

The following is the Index mapping created using NEST .AutoMap from object

```
{
  "staff" : {
    "mappings" : {
      "staff" : {
        "properties" : {
          "dob" : {
            "type" : "date"
          },
          "id" : {
            "type" : "text",
            "fields" : {
              "keyword" : {
                "type" : "keyword",
                "ignore_above" : 256
              }
            }
          },
          "salary" : {
            "type" : "float"
          },
          "staffname" : {
            "type" : "text",
            "fields" : {
              "keyword" : {
                "type" : "keyword",
                "ignore_above" : 256
              }
            }
          }
        }
      }
    }
  }
}

```

On using simple query I am getting this result

```
{
  "took" : 0,
  "timed_out" : false,
  "_shards" : {
    "total" : 5,
    "successful" : 5,
    "skipped" : 0,
    "failed" : 0
  },
  "hits" : {
    "total" : 5,
    "max_score" : 1.0,
    "hits" : [
      {
        "_index" : "staff",
        "_type" : "staff",
        "_id" : "15530",
        "_score" : 1.0,
        "_source" : {
          "id" : "15530",
          "staffname" : "muhammad khayyam",
          "dob" : "1995-08-01T00:00:00",
          "salary" : 20000.0
        }
      },
      {
        "_index" : "staff",
        "_type" : "staff",
        "_id" : "15525",
        "_score" : 1.0,
        "_source" : {
          "id" : "15525",
          "staffname" : "muhammad khayyam",
          "dob" : "1995-08-01T00:00:00",
          "salary" : 50000.0
        }
      },
      {
        "_index" : "staff",
        "_type" : "staff",
        "_id" : "15526",
        "_score" : 1.0,
        "_source" : {
          "id" : "15526",
          "staffname" : "muhammad khayyam",
          "dob" : "1995-08-01T00:00:00",
          "salary" : 80000.0
        }
      },
      {
        "_index" : "staff",
        "_type" : "staff",
        "_id" : "15527",
        "_score" : 1.0,
        "_source" : {
          "id" : "15527",
          "staffname" : "muhammad khayyam",
          "dob" : "1995-08-01T00:00:00",
          "salary" : 20000.0
        }
      },
      {
        "_index" : "staff",
        "_type" : "staff",
        "_id" : "15529",
        "_score" : 1.0,
        "_source" : {
          "id" : "15529",
          "staffname" : "muhammad khayyam",
          "dob" : "1995-08-01T00:00:00",
          "salary" : 20000.0
        }
      }
    ]
  }
}

```

my query is

```
POST /staff/_search
{
  "size" : 0,
  "_source" : false,
  "stored_fields" : "_none_",
  "aggregations" : {
    "groupby" : {
      "composite" : {
        "size" : 1000,
        "sources" : [
          {
            "Date of birth" : {
              "terms" : {
                "field" : "dob",
                "missing_bucket" : true,
                "order" : "asc"
              }
            }
          },
          {
            "Salary" : {
              "terms" : {
                "field" : "salary",
                "missing_bucket" : true,
                "order" : "asc"
              }
            }
          }
        ]
      }
    }
  }
}

```

Returning result

```
{
  "took" : 2,
  "timed_out" : false,
  "_shards" : {
    "total" : 5,
    "successful" : 5,
    "skipped" : 0,
    "failed" : 0
  },
  "hits" : {
    "total" : 5,
    "max_score" : 0.0,
    "hits" : []
  },
  "aggregations" : {
    "groupby" : {
      "after_key" : {
        "Date of birth" : 270777600000,
        "Salary" : 80000.0
      },
      "buckets" : [
        {
          "key" : {
            "Date of birth" : 270777600000,
            "Salary" : 20000.0
          },
          "doc_count" : 3
        },
        {
          "key" : {
            "Date of birth" : 270777600000,
            "Salary" : 50000.0
          },
          "doc_count" : 1
        },
        {
          "key" : {
            "Date of birth" : 270777600000,
            "Salary" : 80000.0
          },
          "doc_count" : 1
        }
      ]
    }
  }
}

```

As can be seen that result of Date of birth in Millisecond-to-epoch, need to get it converted to some specified format which is in Human readable form

---

<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 29, 2019, 12:00pm UTC](https://discuss.elastic.co/t/convert-date-to-human-readable-form/188305/2 "2019-07-29T12:00:18Z")

</div>

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