# NumberFormatException For input string: \\"now-1d/d\\""

**URL:** <https://discuss.elastic.co/t/numberformatexception-for-input-string-now-1d-d/150148>\
**Category:** Elasticsearch\
**Created:** [September 27, 2018, 8:37am UTC](https://discuss.elastic.co/t/numberformatexception-for-input-string-now-1d-d/150148 "2018-09-27T08:37:48Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![dirri](https://avatars.discourse-cdn.com/v4/letter/d/90db22/32.png) [@dirri](https://discuss.elastic.co/u/dirri)\
**Post date:** [September 27, 2018, 8:37am UTC](https://discuss.elastic.co/t/numberformatexception-for-input-string-now-1d-d/150148/1 "2018-09-27T08:37:48Z")

</div>

I´m executing a query using range agg on a date field (includes millis since epoch) but this leads to a NumberFormatException:  
The mapping is:  
"mappings": {  
"\_doc": {  
"properties": {  
"~timestamp": {  
"type": "date"  
}  
}  
}  
}

"query": {  
"range" : {  
"~timestamp" : {  
"gte" : "now-1d/d",  
"lt" : "now/d"  
}  
}  
}

"error": {  
"root\_cause": [  
{  
"type": "query\_shard\_exception",  
"reason": "failed to create query: {\n "range" : {\n "~timestamp" : {\n "from" : "now-1d/d",\n "to" : "now/d",\n "include\_lower" : true,\n "include\_upper" : false,\n "boost" : 1.0\n }\n }\n}",  
"index\_uuid": "Y52J5NqWSBeGiY1pCywBIQ",  
"index": "main\_device-2018.09.27"  
}  
],  
"type": "search\_phase\_execution\_exception",  
"reason": "all shards failed",  
"phase": "query",  
"grouped": true,  
"failed\_shards": [  
{  
"shard": 0,  
"index": "main\_device-2018.09.27",  
"node": "u2uNIHjpR2qFGLuqeGAolA",  
"reason": {  
"type": "query\_shard\_exception",  
"reason": "failed to create query: {\n "range" : {\n "~timestamp" : {\n "from" : "now-1d/d",\n "to" : "now/d",\n "include\_lower" : true,\n "include\_upper" : false,\n "boost" : 1.0\n }\n }\n}",  
"index\_uuid": "Y52J5NqWSBeGiY1pCywBIQ",  
"index": "main\_device-2018.09.27",  
"caused\_by": {  
"type": "number\_format\_exception",  
"reason": "For input string: "now-1d/d""  
}  
}  
}  
]  
},  
"status": 400  
}

---

<div class="post-metadata">

**Author:** ![abdon](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/abdon/32/9195_2.png) [@abdon](https://discuss.elastic.co/u/abdon)\
**Post date:** [September 28, 2018, 8:54am UTC](https://discuss.elastic.co/t/numberformatexception-for-input-string-now-1d-d/150148/2 "2018-09-28T08:54:40Z")

</div>

The error message suggests that the `~timestamp` field is not mapped as a date in the `main_device-2018.09.27` index. What could have happened is that when you indexed a document with an epoch millis timestamp, Elasticsearch dynamically mapped it as a field of type long instead of date.

You can retrieve the mapping of the index to check whether that's indeed the case by executing:

```auto
GET main_device-2018.09.27/_mapping

```

---

<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 26, 2018, 8:54am UTC](https://discuss.elastic.co/t/numberformatexception-for-input-string-now-1d-d/150148/3 "2018-10-26T08:54:43Z")

</div>

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