# ElasticSearch date format

**URL:** <https://discuss.elastic.co/t/elasticsearch-date-format/23008>\
**Category:** Elasticsearch\
**Created:** [March 31, 2015, 1:26pm UTC](https://discuss.elastic.co/t/elasticsearch-date-format/23008 "2015-03-31T13:26:42Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![Phani\_Nadiminti](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/phani_nadiminti/32/45381_2.png) [@Phani\_Nadiminti](https://discuss.elastic.co/u/Phani_Nadiminti)\
**Post date:** [March 31, 2015, 1:26pm UTC](https://discuss.elastic.co/t/elasticsearch-date-format/23008/1 "2015-03-31T13:26:42Z")

</div>

Hi All,

when i insert date to elastic search in the format of yyyy-MM-DD  
hh:mm:ss from java api getting date format exception.but when i use  
yyyy-MM-DDThh:mm:ss between them it is inserted fine.please explain me is T  
here elasticsearch standard format?

please explain me functionality of T in date.i used the default mapping  
of elasticsearch i didn't customized any thing.

mapping:

```
"created": {
              "type": "date",
              "format": "dateOptionalTime"
           }, 

```

Thanks  
phani

--  
You received this message because you are subscribed to the Google Groups "elasticsearch" group.  
To unsubscribe from this group and stop receiving emails from it, send an email to [elasticsearch+unsubscribe@googlegroups.com](mailto:elasticsearch+unsubscribe@googlegroups.com).  
To view this discussion on the web visit [https://groups.google.com/d/msgid/elasticsearch/94b29fca-637d-4d73-84fe-6af4b6300611%40googlegroups.com](https://groups.google.com/d/msgid/elasticsearch/94b29fca-637d-4d73-84fe-6af4b6300611%40googlegroups.com).  
For more options, visit [https://groups.google.com/d/optout](https://groups.google.com/d/optout).

---

<div class="post-metadata">

**Author:** ![jmkgreen](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/jmkgreen/32/471_2.png) [@jmkgreen](https://discuss.elastic.co/u/jmkgreen)\
**Post date:** [March 31, 2015, 2:18pm UTC](https://discuss.elastic.co/t/elasticsearch-date-format/23008/2 "2015-03-31T14:18:25Z")

</div>

I am speculating here that you should use the ISO 8601 format for dates  
since this is quite common and has a timezone which yours lacks  
(introducing ambiguity).

The T is a common separator between the date and time parts.

On 31 March 2015 at 14:26, [phani.nadiminti@goktree.com](mailto:phani.nadiminti@goktree.com) wrote:

> Hi All,
> 
> when i insert date to Elasticsearch in the format of yyyy-MM-DD  
> hh:mm:ss from java api getting date format exception.but when i use  
> yyyy-MM-DDThh:mm:ss between them it is inserted fine.please explain me is T  
> here elasticsearch standard format?
> 
> please explain me functionality of T in date.i used the default mapping  
> of elasticsearch i didn't customized any thing.
> 
> mapping:
> 
> ```
> "created": {
> "type": "date",
> "format": "dateOptionalTime"
> },
> 
> ```
> 
> Thanks  
> phani
> 
> --  
> You received this message because you are subscribed to the Google Groups  
> "elasticsearch" group.  
> To unsubscribe from this group and stop receiving emails from it, send an  
> email to [elasticsearch+unsubscribe@googlegroups.com](mailto:elasticsearch+unsubscribe@googlegroups.com).  
> To view this discussion on the web visit  
> [https://groups.google.com/d/msgid/elasticsearch/94b29fca-637d-4d73-84fe-6af4b6300611%40googlegroups.com](https://groups.google.com/d/msgid/elasticsearch/94b29fca-637d-4d73-84fe-6af4b6300611%40googlegroups.com)  
> [https://groups.google.com/d/msgid/elasticsearch/94b29fca-637d-4d73-84fe-6af4b6300611%40googlegroups.com?utm\_medium=email&utm\_source=footer](https://groups.google.com/d/msgid/elasticsearch/94b29fca-637d-4d73-84fe-6af4b6300611%40googlegroups.com?utm_medium=email&utm_source=footer)  
> .  
> For more options, visit [https://groups.google.com/d/optout](https://groups.google.com/d/optout).

--  
You received this message because you are subscribed to the Google Groups "elasticsearch" group.  
To unsubscribe from this group and stop receiving emails from it, send an email to [elasticsearch+unsubscribe@googlegroups.com](mailto:elasticsearch+unsubscribe@googlegroups.com).  
To view this discussion on the web visit [https://groups.google.com/d/msgid/elasticsearch/CAMH6%2BawJXDAs175DFWH5T5z5%2B-UvJgppKjvqPRBehzMX2R%2Bz7A%40mail.gmail.com](https://groups.google.com/d/msgid/elasticsearch/CAMH6%2BawJXDAs175DFWH5T5z5%2B-UvJgppKjvqPRBehzMX2R%2Bz7A%40mail.gmail.com).  
For more options, visit [https://groups.google.com/d/optout](https://groups.google.com/d/optout).

---

<div class="post-metadata">

**Author:** ![Phani\_Nadiminti](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/phani_nadiminti/32/45381_2.png) [@Phani\_Nadiminti](https://discuss.elastic.co/u/Phani_Nadiminti)\
**Post date:** [March 31, 2015, 2:32pm UTC](https://discuss.elastic.co/t/elasticsearch-date-format/23008/3 "2015-03-31T14:32:24Z")

</div>

HI James,

Thanks for quick reply..

so my understanding is while inserting in to elasticsearch we need to  
use T as separator other wise it won't insert in to date field from java  
API because it expecting standard format of ISO 8601 am I right?

Thanks  
phani

On Tuesday, March 31, 2015 at 7:48:42 PM UTC+5:30, James Green wrote:

> I am speculating here that you should use the ISO 8601 format for dates  
> since this is quite common and has a timezone which yours lacks  
> (introducing ambiguity).
> 
> The T is a common separator between the date and time parts.
> 
> On 31 March 2015 at 14:26, \<[phani.n...@goktree.com](mailto:phani.n...@goktree.com) \<javascript:\>\> wrote:
> 
> > Hi All,
> > 
> > when i insert date to Elasticsearch in the format of yyyy-MM-DD  
> > hh:mm:ss from java api getting date format exception.but when i use  
> > yyyy-MM-DDThh:mm:ss between them it is inserted fine.please explain me is T  
> > here elasticsearch standard format?
> > 
> > please explain me functionality of T in date.i used the default mapping  
> > of elasticsearch i didn't customized any thing.
> > 
> > mapping:
> > 
> > ```
> > "created": {
> > "type": "date",
> > "format": "dateOptionalTime"
> > }, 
> > 
> > ```
> > 
> > Thanks  
> > phani
> > 
> > --  
> > You received this message because you are subscribed to the Google Groups  
> > "elasticsearch" group.  
> > To unsubscribe from this group and stop receiving emails from it, send an  
> > email to [elasticsearc...@googlegroups.com](mailto:elasticsearc...@googlegroups.com) \<javascript:\>.  
> > To view this discussion on the web visit  
> > [https://groups.google.com/d/msgid/elasticsearch/94b29fca-637d-4d73-84fe-6af4b6300611%40googlegroups.com](https://groups.google.com/d/msgid/elasticsearch/94b29fca-637d-4d73-84fe-6af4b6300611%40googlegroups.com)  
> > [https://groups.google.com/d/msgid/elasticsearch/94b29fca-637d-4d73-84fe-6af4b6300611%40googlegroups.com?utm\_medium=email&utm\_source=footer](https://groups.google.com/d/msgid/elasticsearch/94b29fca-637d-4d73-84fe-6af4b6300611%40googlegroups.com?utm_medium=email&utm_source=footer)  
> > .  
> > For more options, visit [https://groups.google.com/d/optout](https://groups.google.com/d/optout).

--  
You received this message because you are subscribed to the Google Groups "elasticsearch" group.  
To unsubscribe from this group and stop receiving emails from it, send an email to [elasticsearch+unsubscribe@googlegroups.com](mailto:elasticsearch+unsubscribe@googlegroups.com).  
To view this discussion on the web visit [https://groups.google.com/d/msgid/elasticsearch/0a7fd7e8-b244-42e9-8427-752474250b07%40googlegroups.com](https://groups.google.com/d/msgid/elasticsearch/0a7fd7e8-b244-42e9-8427-752474250b07%40googlegroups.com).  
For more options, visit [https://groups.google.com/d/optout](https://groups.google.com/d/optout).

---

<div class="post-metadata">

**Author:** ![jmkgreen](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/jmkgreen/32/471_2.png) [@jmkgreen](https://discuss.elastic.co/u/jmkgreen)\
**Post date:** [March 31, 2015, 3:10pm UTC](https://discuss.elastic.co/t/elasticsearch-date-format/23008/4 "2015-03-31T15:10:34Z")

</div>

> **[format | Elasticsearch Guide \[8.11\] | Elastic](https://www.elastic.co/guide/en/elasticsearch/reference/current/mapping-date-format.html)**

The T is a standard symbol, not exclusive to any one software project.  
Elasticsearch uses Joda to parse dates, and it looks like the default  
accepts ISO 8601 which I would expect.

On 31 March 2015 at 15:32, [phani.nadiminti@goktree.com](mailto:phani.nadiminti@goktree.com) wrote:

> HI James,
> 
> Thanks for quick reply..
> 
> so my understanding is while inserting in to elasticsearch we need to  
> use T as separator other wise it won't insert in to date field from java  
> API because it expecting standard format of ISO 8601 am I right?
> 
> Thanks  
> phani
> 
> On Tuesday, March 31, 2015 at 7:48:42 PM UTC+5:30, James Green wrote:
> 
> > I am speculating here that you should use the ISO 8601 format for dates  
> > since this is quite common and has a timezone which yours lacks  
> > (introducing ambiguity).
> > 
> > The T is a common separator between the date and time parts.
> > 
> > On 31 March 2015 at 14:26, [phani.n...@goktree.com](mailto:phani.n...@goktree.com) wrote:
> > 
> > > Hi All,
> > > 
> > > when i insert date to Elasticsearch in the format of yyyy-MM-DD  
> > > hh:mm:ss from java api getting date format exception.but when i use  
> > > yyyy-MM-DDThh:mm:ss between them it is inserted fine.please explain me is T  
> > > here elasticsearch standard format?
> > > 
> > > please explain me functionality of T in date.i used the default  
> > > mapping of elasticsearch i didn't customized any thing.
> > > 
> > > mapping:
> > > 
> > > ```
> > > "created": {
> > > "type": "date",
> > > "format": "dateOptionalTime"
> > > },
> > > 
> > > ```
> > > 
> > > Thanks  
> > > phani
> > > 
> > > --  
> > > You received this message because you are subscribed to the Google  
> > > Groups "elasticsearch" group.  
> > > To unsubscribe from this group and stop receiving emails from it, send  
> > > an email to [elasticsearc...@googlegroups.com](mailto:elasticsearc...@googlegroups.com).  
> > > To view this discussion on the web visit [https://groups.google.com/d/](https://groups.google.com/d/)  
> > > msgid/elasticsearch/94b29fca-637d-4d73-84fe-6af4b6300611%  
> > > [40googlegroups.com](http://40googlegroups.com)  
> > > [https://groups.google.com/d/msgid/elasticsearch/94b29fca-637d-4d73-84fe-6af4b6300611%40googlegroups.com?utm\_medium=email&utm\_source=footer](https://groups.google.com/d/msgid/elasticsearch/94b29fca-637d-4d73-84fe-6af4b6300611%40googlegroups.com?utm_medium=email&utm_source=footer)  
> > > .  
> > > For more options, visit [https://groups.google.com/d/optout](https://groups.google.com/d/optout).
> > 
> > --  
> > You received this message because you are subscribed to the Google Groups  
> > "elasticsearch" group.  
> > To unsubscribe from this group and stop receiving emails from it, send an  
> > email to [elasticsearch+unsubscribe@googlegroups.com](mailto:elasticsearch+unsubscribe@googlegroups.com).  
> > To view this discussion on the web visit  
> > [https://groups.google.com/d/msgid/elasticsearch/0a7fd7e8-b244-42e9-8427-752474250b07%40googlegroups.com](https://groups.google.com/d/msgid/elasticsearch/0a7fd7e8-b244-42e9-8427-752474250b07%40googlegroups.com)  
> > [https://groups.google.com/d/msgid/elasticsearch/0a7fd7e8-b244-42e9-8427-752474250b07%40googlegroups.com?utm\_medium=email&utm\_source=footer](https://groups.google.com/d/msgid/elasticsearch/0a7fd7e8-b244-42e9-8427-752474250b07%40googlegroups.com?utm_medium=email&utm_source=footer)  
> > .
> 
> For more options, visit [https://groups.google.com/d/optout](https://groups.google.com/d/optout).

--  
You received this message because you are subscribed to the Google Groups "elasticsearch" group.  
To unsubscribe from this group and stop receiving emails from it, send an email to [elasticsearch+unsubscribe@googlegroups.com](mailto:elasticsearch+unsubscribe@googlegroups.com).  
To view this discussion on the web visit [https://groups.google.com/d/msgid/elasticsearch/CAMH6%2BawqvJ\_DOZUR2u7C%3DU7AvFFr%3DhyBoBTMRwCbdow7kZxOsg%40mail.gmail.com](https://groups.google.com/d/msgid/elasticsearch/CAMH6%2BawqvJ_DOZUR2u7C%3DU7AvFFr%3DhyBoBTMRwCbdow7kZxOsg%40mail.gmail.com).  
For more options, visit [https://groups.google.com/d/optout](https://groups.google.com/d/optout).

---

<div class="post-metadata">

**Author:** ![Phani\_Nadiminti](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/phani_nadiminti/32/45381_2.png) [@Phani\_Nadiminti](https://discuss.elastic.co/u/Phani_Nadiminti)\
**Post date:** [April 3, 2015, 11:58am UTC](https://discuss.elastic.co/t/elasticsearch-date-format/23008/5 "2015-04-03T11:58:18Z")

</div>

Hi james,

Thanks for the reply under stood your point please walk through the  
following scenario i found.

I have important scenario to share with you.

I created index it contains date field no format was specified.

the following is the mapping :

```
"created" :{

```

"type" : "date",  
"format" : "dateOptionalTime"  
}  
when I index data using river the date is inserting in the following  
format : "2015-03-06T18:04:15.000-06:00" automatically.  
due to this I am getting my daily record counts. but if the date format is  
2015-03-06T18:04:15.000Z like this it is working fine and showing  
daily counts fine  
But from database my date is coming like this '2015-03-01 00:00:00' So how  
can we control the date from river while indexing in to elasticsearch  
which should be display in 2015-03-06T18:04:15.000Z format.  
please suggest me on this due to this my monthly sales also not showing  
correctly.is there any custom date format need to define when data is  
populating  
using river from database.  
why "-06:00" this is appending at the end of each date please explain me  
this concept?

Thanks,  
phani

On Tuesday, March 31, 2015 at 8:40:49 PM UTC+5:30, James Green wrote:

> [format | Elasticsearch Guide [8.11] | Elastic](http://www.elastic.co/guide/en/elasticsearch/reference/current/mapping-date-format.html)
> 
> The T is a standard symbol, not exclusive to any one software project.  
> Elasticsearch uses Joda to parse dates, and it looks like the default  
> accepts ISO 8601 which I would expect.
> 
> On 31 March 2015 at 15:32, \<[phani.n...@goktree.com](mailto:phani.n...@goktree.com) \<javascript:\>\> wrote:
> 
> > HI James,
> > 
> > Thanks for quick reply..
> > 
> > so my understanding is while inserting in to elasticsearch we need to  
> > use T as separator other wise it won't insert in to date field from java  
> > API because it expecting standard format of ISO 8601 am I right?
> > 
> > Thanks  
> > phani
> > 
> > On Tuesday, March 31, 2015 at 7:48:42 PM UTC+5:30, James Green wrote:
> > 
> > > I am speculating here that you should use the ISO 8601 format for dates  
> > > since this is quite common and has a timezone which yours lacks  
> > > (introducing ambiguity).
> > > 
> > > The T is a common separator between the date and time parts.
> > > 
> > > On 31 March 2015 at 14:26, [phani.n...@goktree.com](mailto:phani.n...@goktree.com) wrote:
> > > 
> > > > Hi All,
> > > > 
> > > > when i insert date to Elasticsearch in the format of yyyy-MM-DD  
> > > > hh:mm:ss from java api getting date format exception.but when i use  
> > > > yyyy-MM-DDThh:mm:ss between them it is inserted fine.please explain me is T  
> > > > here elasticsearch standard format?
> > > > 
> > > > please explain me functionality of T in date.i used the default  
> > > > mapping of elasticsearch i didn't customized any thing.
> > > > 
> > > > mapping:
> > > > 
> > > > ```
> > > > "created": {
> > > > "type": "date",
> > > > "format": "dateOptionalTime"
> > > > }, 
> > > > 
> > > > ```
> > > > 
> > > > Thanks  
> > > > phani
> > > > 
> > > > --  
> > > > You received this message because you are subscribed to the Google  
> > > > Groups "elasticsearch" group.  
> > > > To unsubscribe from this group and stop receiving emails from it, send  
> > > > an email to [elasticsearc...@googlegroups.com](mailto:elasticsearc...@googlegroups.com).  
> > > > To view this discussion on the web visit [https://groups.google.com/d/](https://groups.google.com/d/)  
> > > > msgid/elasticsearch/94b29fca-637d-4d73-84fe-6af4b6300611%  
> > > > [40googlegroups.com](http://40googlegroups.com)  
> > > > [https://groups.google.com/d/msgid/elasticsearch/94b29fca-637d-4d73-84fe-6af4b6300611%40googlegroups.com?utm\_medium=email&utm\_source=footer](https://groups.google.com/d/msgid/elasticsearch/94b29fca-637d-4d73-84fe-6af4b6300611%40googlegroups.com?utm_medium=email&utm_source=footer)  
> > > > .  
> > > > For more options, visit [https://groups.google.com/d/optout](https://groups.google.com/d/optout).
> > > 
> > > --  
> > > You received this message because you are subscribed to the Google Groups  
> > > "elasticsearch" group.  
> > > To unsubscribe from this group and stop receiving emails from it, send an  
> > > email to [elasticsearc...@googlegroups.com](mailto:elasticsearc...@googlegroups.com) \<javascript:\>.  
> > > To view this discussion on the web visit  
> > > [https://groups.google.com/d/msgid/elasticsearch/0a7fd7e8-b244-42e9-8427-752474250b07%40googlegroups.com](https://groups.google.com/d/msgid/elasticsearch/0a7fd7e8-b244-42e9-8427-752474250b07%40googlegroups.com)  
> > > [https://groups.google.com/d/msgid/elasticsearch/0a7fd7e8-b244-42e9-8427-752474250b07%40googlegroups.com?utm\_medium=email&utm\_source=footer](https://groups.google.com/d/msgid/elasticsearch/0a7fd7e8-b244-42e9-8427-752474250b07%40googlegroups.com?utm_medium=email&utm_source=footer)  
> > > .
> > 
> > For more options, visit [https://groups.google.com/d/optout](https://groups.google.com/d/optout).

--  
You received this message because you are subscribed to the Google Groups "elasticsearch" group.  
To unsubscribe from this group and stop receiving emails from it, send an email to [elasticsearch+unsubscribe@googlegroups.com](mailto:elasticsearch+unsubscribe@googlegroups.com).  
To view this discussion on the web visit [https://groups.google.com/d/msgid/elasticsearch/73bfba69-bff2-48e4-ad72-fad46c9dc124%40googlegroups.com](https://groups.google.com/d/msgid/elasticsearch/73bfba69-bff2-48e4-ad72-fad46c9dc124%40googlegroups.com).  
For more options, visit [https://groups.google.com/d/optout](https://groups.google.com/d/optout).

---

<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, 12:21am UTC](https://discuss.elastic.co/t/elasticsearch-date-format/23008/6 "2017-07-06T00:21:51Z")

</div>


