# Timestamp update

**URL:** <https://discuss.elastic.co/t/timestamp-update/262110>\
**Category:** Elasticsearch\
**Created:** [January 25, 2021, 1:30pm UTC](https://discuss.elastic.co/t/timestamp-update/262110 "2021-01-25T13:30:21Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![Makss39](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/makss39/32/74694_2.png) [@Makss39](https://discuss.elastic.co/u/Makss39)\
**Post date:** [January 25, 2021, 1:30pm UTC](https://discuss.elastic.co/t/timestamp-update/262110/1 "2021-01-25T13:30:21Z")

</div>

Hello !

I would like to update my timestamp field, but all the info that i've found are not working...  
Probably a synthax error but i'm not able to figure out where it stucks... I already tried several option...

```
POST myindex/_update_by_query
{
    "script" : {
      "source": "ctx._source.timestamp = '2020-01-30T23:00:00.000Z';",
      "lang": "painless"
    },
    "query": {
        "term" : {
            "@timestamp": "2019-12-31T23:00:00.000Z"
        }
    }
}

```

Here is the result:

```
 {
      "index" : "myindex",
      "type" : "_doc",
      "id" : "zv9hMncB6BPk8lMws2HZ",
      "cause" : {
        "type" : "mapper_parsing_exception",
        "reason" : "failed to parse field [timestamp] of type [long] in document with id 'zv9hMncB6BPk8lMws2HZ'. Preview of field's value: '2020-01-30T23:00:00.000Z'",
        "caused_by" : {
          "type" : "illegal_argument_exception",
          "reason" : "For input string: \"2020-01-30T23:00:00.000Z\""
        }
      },
      "status" : 400
    },
```

---

<div class="post-metadata">

**Author:** ![dadoonet](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/dadoonet/32/137187_2.png) [@dadoonet](https://discuss.elastic.co/u/dadoonet)\
**Post date:** [January 25, 2021, 2:53pm UTC](https://discuss.elastic.co/t/timestamp-update/262110/2 "2021-01-25T14:53:20Z")

</div>

It seems that the mapping for the field `timestamp` is a `long` and not a `date` so you can't do that.

---

<div class="post-metadata">

**Author:** ![Makss39](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/makss39/32/74694_2.png) [@Makss39](https://discuss.elastic.co/u/Makss39)\
**Post date:** [January 25, 2021, 3:21pm UTC](https://discuss.elastic.co/t/timestamp-update/262110/3 "2021-01-25T15:21:15Z")

</div>

After several tries, i got it working:

`"source": "ctx._source['@timestamp'] = '2018-03-30T23:00:00.000Z';"`

---

<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, 2021, 3:21pm UTC](https://discuss.elastic.co/t/timestamp-update/262110/4 "2021-02-22T15:21:25Z")

</div>

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