# Date fields not being treated as timestamp fields in Kibana index patterns

**URL:** https://discuss.elastic.co/t/date-fields-not-being-treated-as-timestamp-fields-in-kibana-index-patterns/295310
**Category:** Kibana
**Created:** [January 25, 2022, 7:03am UTC](https://discuss.elastic.co/t/date-fields-not-being-treated-as-timestamp-fields-in-kibana-index-patterns/295310 "2022-01-25T07:03:00Z")
**Posts on this page:** 4
**Page:** 1

<div class="post-metadata">

### Author: ![abhinav\_chourasia](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/abhinav_chourasia/32/41855_2.png) [@abhinav\_chourasia](https://discuss.elastic.co/u/abhinav_chourasia)
#### Post date: [January 25, 2022, 7:03am UTC](https://discuss.elastic.co/t/date-fields-not-being-treated-as-timestamp-fields-in-kibana-index-patterns/295310/1 "2022-01-25T07:03:00Z")

</div>

I have been trying to get the mapping correct for my date values in my documents. I have come down to doing a lot of hit and trial now with it. Every time and no matter what option I try, I am not getting the date field in my document treated as a timestamp column while creating Kibana index patterns.

Here are the various options I have tried (hit and trial because I feel like a total noob with ELK 😊) with my index mappings:

**trial 1:**

```
{
    "mappings" : {
        "properties" : {
                 "Created" : {
          "type" : "date",
          "fields" : {
            "keyword" : {
              "type" : "keyword"
            }
          },
          "format": "strict_date_optional_time||epoch_millis"
        },
        "Due date" : {
          "type" : "date",
          "fields" : {
            "keyword" : {
              "type" : "keyword"
            }
          },
          "format": "strict_date_optional_time||epoch_millis"
        },
        "Updated" : {
          "type" : "date",
          "fields" : {
            "keyword" : {
              "type" : "keyword"
            }
          },
          "format": "strict_date_optional_time||epoch_millis"
        }
      }
    }
}

```

**trial 2**

```
    {
    "mappings" : {
        "properties" : {
                 "Created" : {
          "type" : "date",
          "fields" : {
            "keyword" : {
              "type" : "keyword"
            }
          }          
        },
        "Due date" : {
          "type" : "date",
          "fields" : {
            "keyword" : {
              "type" : "keyword"
            }
          }
        },
        "Updated" : {
          "type" : "date",
          "fields" : {
            "keyword" : {
              "type" : "keyword"
            }
          }
        }
      }
    }
}

```

**trial 3**

```
    {
    "mappings" : {
        "properties" : {
                 "Created" : {
          "type" : "date",
          "fields" : {
            "keyword" : {
              "type" : "date"
            }
          }          
        },
        "Due date" : {
          "type" : "date",
          "fields" : {
            "keyword" : {
              "type" : "date"
            }
          }
        },
        "Updated" : {
          "type" : "date",
          "fields" : {
            "keyword" : {
              "type" : "date"
            }
          }
        }
      }
    }
}

```

And then each of the trials above with the below :

```
    "_default_": {
  "_timestamp": {
    "enabled": true,
    "store": true,
    "_field_names": "_timestamp"
  }
},

```

and then each of the

```
  "fields" : {
    "keyword" : {
      "type" : "date"
    }

```

specified with the format again explicitly with each of the above combinations.  
and that’s how my sample document looks like (different trials)

**trial doc 1**

```
{ "Created": "15/11/21 13:21",
  "Updated": "30/12/21 14:30",
  "Due date": null
}

```

**tried doc 2**

```auto
{ 
  "Created": 1636982460000,
  "Updated": 1640874600000,
  "Due date": null
}

```

and none of the above combinations seems to make the needed fields as a timestamp field while creating the index patterns in Kibana, (Elasticsearch & Kibana 7.15)

I am sure there is a lot to learn here. Could someone please guide in the right direction? Lest I end up writing an automation for generating the various combinations (and ofcourse that would be brainless & for sure not lead to any good 😄 )

---

<div class="post-metadata">

### Author: ![tsullivan](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/tsullivan/32/31077_2.png) [@tsullivan](https://discuss.elastic.co/u/tsullivan)
#### Post date: [January 25, 2022, 8:16pm UTC](https://discuss.elastic.co/t/date-fields-not-being-treated-as-timestamp-fields-in-kibana-index-patterns/295310/2 "2022-01-25T20:16:11Z")

</div>

Have you tried without using [multi-fields](https://www.elastic.co/guide/en/elasticsearch/reference/current/multi-fields.html)?

1. Add an index template that will match the indices with your data:

```auto
PUT /_index_template/abhinavlogs-dev
{
  "index_patterns": ["abhinavlogs-*"],
  "template": {
    "mappings": {
      "properties": {
        "Created": { "type": "date" },
        "Updated": { "type": "date" },
        "DueDate": { "type": "date" } # Note: do not put spaces in the field name.
      }
    }
  }
}

```

1. Index data into the matching index:

```auto
POST /abhinavlogs-001/_doc
{
  "Created": "2022-01-25T20:02:13Z",
  "Updated": "2022-01-25T20:02:13Z",
  "DueDate": null
}

```

1. Check the mapping of the index

```auto
GET /abhinavlogs-001/_mapping

```

 ![image](https://us1.discourse-cdn.com/elastic/original/3X/3/b/3bdf31b0d652500a85803452fb8b49fae71a7c02.png)

I haven't tried using multi-fields for the date fields, but if you start with this, maybe you can work up to what you really need.

---

<div class="post-metadata">

### Author: ![tsullivan](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/tsullivan/32/31077_2.png) [@tsullivan](https://discuss.elastic.co/u/tsullivan)
#### Post date: [January 25, 2022, 8:17pm UTC](https://discuss.elastic.co/t/date-fields-not-being-treated-as-timestamp-fields-in-kibana-index-patterns/295310/3 "2022-01-25T20:17:44Z")

</div>

BTW, you don't need to have spaces in the field name. You can put a custom label on the field to make it show up with a space in Kibana:

 ![image](https://us1.discourse-cdn.com/elastic/original/3X/e/d/edf0943ac06ef18772d234b84154c17ae7d141ba.png)

---

<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: [February 22, 2022, 8:17pm UTC](https://discuss.elastic.co/t/date-fields-not-being-treated-as-timestamp-fields-in-kibana-index-patterns/295310/4 "2022-02-22T20:17:49Z")

</div>

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