# Update timestamp from millis to second in all documents

**URL:** <https://discuss.elastic.co/t/update-timestamp-from-millis-to-second-in-all-documents/170792>\
**Category:** Elasticsearch\
**Created:** [March 4, 2019, 8:44pm UTC](https://discuss.elastic.co/t/update-timestamp-from-millis-to-second-in-all-documents/170792 "2019-03-04T20:44:23Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Aliya](https://avatars.discourse-cdn.com/v4/letter/a/43a26b/32.png) [@Aliya](https://discuss.elastic.co/u/Aliya)\
**Post date:** [March 4, 2019, 8:44pm UTC](https://discuss.elastic.co/t/update-timestamp-from-millis-to-second-in-all-documents/170792/1 "2019-03-04T20:44:24Z")

</div>

I'm trying to update my timestamps from milliseconds to seconds while re-indexing but i'm not sure how to do it. We are using elasticsearch 2.4.6 which in turn uses groovy script.

My script looks like below: (i know this not the best way to do it)

```
    "script":{"inline":"ctx._source.service.created=DateTime.parse(ctx._source.service.created)/1000"}

```

i got the below Error when i'm executing the script

```
{

 "error": {
   "root_cause": [
     {
       "type": "script_exception",
       "reason": "failed to run inline script [ctx._source.service.created=DateTime.parse(ctx._source.service.created)/1000] using lang [groovy]"}],
   "type": "script_exception",
   "reason": "failed to run inline script [ctx._source.service.created=DateTime.parse(ctx._source.service.created)/1000] using lang [groovy]",
      "caused_by": {
              "type": "missing_method_exception",
              "reason": "No signature of method: org.joda.time.DateTime.div() is applicable for argument types: (java.lang.Integer) values: [1000] Possible solutions: is(java.lang.Object), wait(), era(), now(), find(), dump()"}},
"status": 500

}

```

My mappings looks like this

```
{  
  "es" : {
     "properties" : {
             "service" : {
                     "created" : {
					      "format": "epoch_second||dateOptionalTime",
					      "type": "date"
				      }
                }
       }
   }
}

```

Any suggestions could be helpful

---

<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:** [April 1, 2019, 8:44pm UTC](https://discuss.elastic.co/t/update-timestamp-from-millis-to-second-in-all-documents/170792/2 "2019-04-01T20:44:27Z")

</div>

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