# Mapping ISO date

**URL:** <https://discuss.elastic.co/t/mapping-iso-date/8414>\
**Category:** Elasticsearch\
**Created:** [July 13, 2012, 8:09pm UTC](https://discuss.elastic.co/t/mapping-iso-date/8414 "2012-07-13T20:09:24Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![coys](https://avatars.discourse-cdn.com/v4/letter/c/eb8c5e/32.png) [@coys](https://discuss.elastic.co/u/coys)\
**Post date:** [July 13, 2012, 8:09pm UTC](https://discuss.elastic.co/t/mapping-iso-date/8414/1 "2012-07-13T20:09:24Z")

</div>

Hello, I have a date stored in mongo as "creationDate" :  
ISODate("2012-07-13T19:16:28.962Z").  
The mapping created for creationDate is as follows  
"creationDate" : {  
"type" : "date",  
"format" : "dateOptionalTime"  
},  
which is created by default when I store the mongo document in es.

However, the date stored in es is as follows  
"creationDate":"2012-07-13T19:16:28.962Z"

As you can see, it is not stored as ISODate..it stipped out the string  
part of the date even though I've mapped it as date. Can you please  
tell me what I need to change so that it's stored as an ISODate and  
not a string

Btw, with the range query I'm still able to enter say  
2012-07-13T19:16:28.962Z so I can create a range query on 2 dates  
which is cool but I'd still like to store it as say  
ISODate("2012-07-13T19:16:28.962Z"). Thanks!

---

<div class="post-metadata">

**Author:** ![jprante](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/jprante/32/44941_2.png) [@jprante](https://discuss.elastic.co/u/jprante)\
**Post date:** [July 14, 2012, 11:15pm UTC](https://discuss.elastic.co/t/mapping-iso-date/8414/2 "2012-07-14T23:15:52Z")

</div>

Dates in Elasticsearch are represented in ISO date format, so if you find  
"2012-07-13T19:16:28.962Z"" in JSON, it is a valid representation.  
Elasticsearch would have reported an error if the date value had been  
invalid. Internally, a date is stored as a long.

Best regards,

Jörg

On Friday, July 13, 2012 10:09:24 PM UTC+2, coys wrote:

> Hello, I have a date stored in mongo as "creationDate" :  
> ISODate("2012-07-13T19:16:28.962Z").  
> The mapping created for creationDate is as follows  
> "creationDate" : {  
> "type" : "date",  
> "format" : "dateOptionalTime"  
> },  
> which is created by default when I store the mongo document in es.
> 
> However, the date stored in es is as follows  
> "creationDate":"2012-07-13T19:16:28.962Z"
> 
> As you can see, it is not stored as ISODate..it stipped out the string  
> part of the date even though I've mapped it as date. Can you please  
> tell me what I need to change so that it's stored as an ISODate and  
> not a string
> 
> Btw, with the range query I'm still able to enter say  
> 2012-07-13T19:16:28.962Z so I can create a range query on 2 dates  
> which is cool but I'd still like to store it as say  
> ISODate("2012-07-13T19:16:28.962Z"). Thanks!

---

<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:** [July 6, 2017, 3:20am UTC](https://discuss.elastic.co/t/mapping-iso-date/8414/3 "2017-07-06T03:20:16Z")

</div>


