# Can't use specific date field as primary time field

**URL:** https://discuss.elastic.co/t/cant-use-specific-date-field-as-primary-time-field/273542
**Category:** Kibana
**Created:** [May 20, 2021, 1:08pm UTC](https://discuss.elastic.co/t/cant-use-specific-date-field-as-primary-time-field/273542 "2021-05-20T13:08:04Z")
**Posts on this page:** 5
**Page:** 1

<div class="post-metadata">

### Author: ![Travis](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/travis/32/54079_2.png) [@Travis](https://discuss.elastic.co/u/Travis)
#### Post date: [May 20, 2021, 1:08pm UTC](https://discuss.elastic.co/t/cant-use-specific-date-field-as-primary-time-field/273542/1 "2021-05-20T13:08:05Z")

</div>

Hello !

I have the field "Generated Time" in my message. I want to use it as primary date field in Kibana.

To do so, I create my index pattern and choose "Generated Time" as primary date field. But once in Discover, nothing is displayed. Like if Kibana don't understand this field.

![Capture2](https://us1.discourse-cdn.com/elastic/original/3X/3/7/3785ce6b776d8260364916017b0258c3f5b532ff.png)

 ![Capture](https://us1.discourse-cdn.com/elastic/original/3X/5/2/52c0ca8b6cef02eeaa661e40854f7380d4a9c134.png)

GET myindex/\_search :

```
{
  "took" : 0,
  "timed_out" : false,
  "_shards" : {
    "total" : 1,
    "successful" : 1,
    "skipped" : 0,
    "failed" : 0
  },
  "hits" : {
    "total" : {
      "value" : 1,
      "relation" : "eq"
    },
    "max_score" : 1.0,
    "hits" : [
      {
        "_index" : "palo",
        "_type" : "_doc",
        "_id" : "lZdviXkBTGy11OBhDMD8",
        "_score" : 1.0,
        "_source" : {
          "@timestamp" : "2021-05-20T11:00:30.917Z",
          "Receive Time" : "2021/05/20 14:06:46",
          "Packets Received" : "1",
          "Session ID" : "1299262",
          "Destination Port" : "53",
          "Destination VM UUID" : null,
          "Generated Time" : "2021/05/20 14:06:46",
          "NAT Destination IP" : "0.0.0.0",
          "Monitor Tag/IMEI" : null,
          "SCTP Chunks Sent" : "0",
          "syslog_timestamp" : "May 20 14:06:47",
          "Device Group Hierarchy Level 1" : "1829",
          "NAT Destination Port" : "0"
        }
      }
    ]
  }
}

```

mapping :

```
"Generated Time" : {
  "type" : "date",
  "format" : "yyyy/MM/dd HH:mm:ss||yyyy/MM/dd||epoch_millis"
},

```

If I choose @timestamp as primary date field, it works. I can see the log.

Thanks for your help !

---

<div class="post-metadata">

### Author: ![flash1293](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/flash1293/32/41227_2.png) [@flash1293](https://discuss.elastic.co/u/flash1293)
#### Post date: [May 20, 2021, 1:50pm UTC](https://discuss.elastic.co/t/cant-use-specific-date-field-as-primary-time-field/273542/2 "2021-05-20T13:50:31Z")

</div>

In Discover there's an "Inspect" button in the top right - could you copy/paste the request Discover is doing here? I suspect the space in the field name to be problematic.

---

<div class="post-metadata">

### Author: ![Travis](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/travis/32/54079_2.png) [@Travis](https://discuss.elastic.co/u/Travis)
#### Post date: [May 20, 2021, 6:03pm UTC](https://discuss.elastic.co/t/cant-use-specific-date-field-as-primary-time-field/273542/3 "2021-05-20T18:03:31Z")

</div>

Strange...

I changed

```
"Generated Time" : {
  "type" : "date",
  "format" : "yyyy/MM/dd HH:mm:ss||yyyy/MM/dd||epoch_millis"
},

```

with

```
"Generated Time" : {
  "type" : "date",
  "format" : "yyyy/MM/dd HH:mm:ss"
},

```

and now it's working.

Two pipe in date format = "or" right ?

---

<div class="post-metadata">

### Author: ![Travis](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/travis/32/54079_2.png) [@Travis](https://discuss.elastic.co/u/Travis)
#### Post date: [May 21, 2021, 9:22am UTC](https://discuss.elastic.co/t/cant-use-specific-date-field-as-primary-time-field/273542/4 "2021-05-21T09:22:35Z")

</div>

Hmm...it looks like it was not representativ as it doesn't working anymore (I juste tested with one log yesterday)

Here is the request Discover @flash1293

```
{
  "version": true,
  "size": 500,
  "sort": [
    {
      "Generated Time": {
        "order": "desc",
        "unmapped_type": "boolean"
      }
    }
  ],
  "aggs": {
    "2": {
      "date_histogram": {
        "field": "Generated Time",
        "calendar_interval": "1d",
        "time_zone": "UTC",
        "min_doc_count": 1
      }
    }
  },
  "stored_fields": [
    "*"
  ],
  "script_fields": {},
  "docvalue_fields": [
    {
      "field": "@timestamp",
      "format": "date_time"
    },
    {
      "field": "Generated Time",
      "format": "date_time"
    },
    {
      "field": "Receive Time",
      "format": "date_time"
    },
    {
      "field": "Start Time",
      "format": "date_time"
    }
  ],
  "_source": {
    "excludes": []
  },
  "query": {
    "bool": {
      "must": [],
      "filter": [
        {
          "match_all": {}
        },
        {
          "range": {
            "Generated Time": {
              "gte": "2021-02-20T09:20:05.739Z",
              "lte": "2021-05-21T09:20:05.739Z",
              "format": "strict_date_optional_time"
            }
          }
        }
      ],
      "should": [],
      "must_not": []
    }
  },
  "highlight": {
    "pre_tags": [
      "@kibana-highlighted-field@"
    ],
    "post_tags": [
      "@/kibana-highlighted-field@"
    ],
    "fields": {
      "*": {}
    },
    "fragment_size": 2147483647
  }
}
```

---

<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: [June 18, 2021, 9:22am UTC](https://discuss.elastic.co/t/cant-use-specific-date-field-as-primary-time-field/273542/5 "2021-06-18T09:22:43Z")

</div>

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