# Single field with multiple date types (date and date\_nanos)

**URL:** <https://discuss.elastic.co/t/single-field-with-multiple-date-types-date-and-date-nanos/211726>\
**Category:** Elasticsearch\
**Created:** [December 12, 2019, 9:34pm UTC](https://discuss.elastic.co/t/single-field-with-multiple-date-types-date-and-date-nanos/211726 "2019-12-12T21:34:52Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![data\_smith](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/data_smith/32/124122_2.png) [@data\_smith](https://discuss.elastic.co/u/data_smith)\
**Post date:** [December 12, 2019, 9:34pm UTC](https://discuss.elastic.co/t/single-field-with-multiple-date-types-date-and-date-nanos/211726/1 "2019-12-12T21:34:52Z")

</div>

Is it possible to have a single field have multiple date types (date and date\_nanos)? I need date\_nanos for the precision but certain tools, such as Kibana streaming logs, only support regular date. So i'd like to index the field two different ways - one as date and the other as date\_nanos. Is this possible?

---

<div class="post-metadata">

**Author:** ![abdon](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/abdon/32/9195_2.png) [@abdon](https://discuss.elastic.co/u/abdon)\
**Post date:** [December 14, 2019, 12:27pm UTC](https://discuss.elastic.co/t/single-field-with-multiple-date-types-date-and-date-nanos/211726/2 "2019-12-14T12:27:56Z")

</div>

Yes, you could use [multifields](https://www.elastic.co/guide/en/elasticsearch/reference/current/multi-fields.html) for that. Multifields allow you to index the same value in different ways.

For example, if you define your mapping like this:

```auto
PUT my_index
{
  "mappings": {
    "properties": {
      "my_date": {
        "type": "date",
        "fields": {
          "nanos": {
            "type": "date_nanos"
          }
        }
      }
    }
  }
}

```

Then you can use the `my_date` field if you need millisecond precision, or `my_date.nanos` if you need nanosecond precision.

---

<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:** [January 11, 2020, 12:28pm UTC](https://discuss.elastic.co/t/single-field-with-multiple-date-types-date-and-date-nanos/211726/3 "2020-01-11T12:28:04Z")

</div>

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