# Updating date fields not working

**URL:** https://discuss.elastic.co/t/updating-date-fields-not-working/199492
**Category:** Elasticsearch
**Created:** [September 14, 2019, 4:12am UTC](https://discuss.elastic.co/t/updating-date-fields-not-working/199492 "2019-09-14T04:12:58Z")
**Posts on this page:** 5
**Page:** 1

<div class="post-metadata">

### Author: ![ebdavison](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/ebdavison/32/47575_2.png) [@ebdavison](https://discuss.elastic.co/u/ebdavison)
#### Post date: [September 14, 2019, 4:12am UTC](https://discuss.elastic.co/t/updating-date-fields-not-working/199492/1 "2019-09-14T04:12:58Z")

</div>

I have a document that I am trying to update and it contains a date. If the source gets updated (in a RDBMS) then I am trying to update the document in elasticsearch.

The document, ID 1, is like this:

```auto
    {
        '@timestamp': '2019-09-12T10:00:00',
        'created_time': '2019-09-12T10:00:00',
        'updated_time': '2019-09-12T10:00:00',
        'fname': 'joe',
        'lname': 'smyth'
    }

```

The update doc, also ID 1, looks like:

```auto
    {
        '@timestamp': '2019-09-12T10:00:00',
        'created_time': '2019-09-12T10:00:00',
        'updated_time': '2019-09-12T11:30:00',
        'fname': 'joe',
        'lname': 'smyth'
    }

```

If I do an insert (`PUT /index/1`) and replace the entire document, the version is incremented BUT the update\_time field is NOT changed.  
If I do an update (`POST /index/_update/1`) then nothing is updated (result is `noop`).

What gives? Are dates NON-updateable?

---

<div class="post-metadata">

### Author: ![ebdavison](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/ebdavison/32/47575_2.png) [@ebdavison](https://discuss.elastic.co/u/ebdavison)
#### Post date: [September 14, 2019, 2:23pm UTC](https://discuss.elastic.co/t/updating-date-fields-not-working/199492/2 "2019-09-14T14:23:53Z")

</div>

Just a follow-up note on this, I did some more testing and found that if I change `lname` to `smith` and also change `updated_time` then, as expected `lname` is properly updated. However, `updated_time` is still NOT updated. Both methods (index and update) result in the update of `lname` but NOT `updated_time`.

---

<div class="post-metadata">

### Author: ![ebdavison](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/ebdavison/32/47575_2.png) [@ebdavison](https://discuss.elastic.co/u/ebdavison)
#### Post date: [September 15, 2019, 8:48pm UTC](https://discuss.elastic.co/t/updating-date-fields-not-working/199492/3 "2019-09-15T20:48:31Z")

</div>

I was able to print the result of the update and with only the date in the update command (`updated_time`), as such:

```auto
{'doc': {'updated_time': '2019-09-15T22:55:26.079445'}}

```

The result is:

```auto
{'_index': 'index', '_type': 'doc', '_id': '999999', '_version': 5, 
'result': 'noop', '_shards': {'total': 0, 'successful': 0, 'failed': 0}}

```

---

<div class="post-metadata">

### Author: ![spinscale](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/spinscale/32/25011_2.png) [@spinscale](https://discuss.elastic.co/u/spinscale)
#### Post date: [September 16, 2019, 1:40pm UTC](https://discuss.elastic.co/t/updating-date-fields-not-working/199492/4 "2019-09-16T13:40:19Z")

</div>

can you please share a **fully** reproducible example including index creation, document indexing and updating along with the elasticsearch version you are using? Thank you!

---

<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: [October 14, 2019, 1:40pm UTC](https://discuss.elastic.co/t/updating-date-fields-not-working/199492/5 "2019-10-14T13:40:20Z")

</div>

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