# Not able to sort date

**URL:** <https://discuss.elastic.co/t/not-able-to-sort-date/161444>\
**Category:** Elasticsearch\
**Created:** [December 19, 2018, 5:34am UTC](https://discuss.elastic.co/t/not-able-to-sort-date/161444 "2018-12-19T05:34:28Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![PK1210](https://avatars.discourse-cdn.com/v4/letter/p/8c91f0/32.png) [@PK1210](https://discuss.elastic.co/u/PK1210)\
**Post date:** [December 19, 2018, 5:34am UTC](https://discuss.elastic.co/t/not-able-to-sort-date/161444/1 "2018-12-19T05:34:28Z")

</div>

[https://www.elastic.co/guide/en/elasticsearch/reference/current/date.html](https://www.elastic.co/guide/en/elasticsearch/reference/current/date.html)  
I have been trying to sort my posts on basis of createDate but it does not seem to be working  
Index -  
"createDate":{  
"type":"date",  
"format":"dd/MM/yyyy||dd/M/yyyy||d/MM/yyyy||d/M/yyyy"  
},

My query is GET /posts/post/\_search?q=\*  
Body -  
{  
"sort":[{  
"createDate":{"order":"desc"}  
}]  
}

As a response the dates 16/11/2018 and 8/11/2018 are not differentiated by sort in any way and their relative order remains same both in ascending and descending order.

---

<div class="post-metadata">

**Author:** ![warkolm](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/warkolm/32/39224_2.png) [@warkolm](https://discuss.elastic.co/u/warkolm)\
**Post date:** [December 19, 2018, 5:44am UTC](https://discuss.elastic.co/t/not-able-to-sort-date/161444/2 "2018-12-19T05:44:02Z")

</div>

Having a topic title that is a URL doesn't provide any info about what you are asking and is less likely to encourage people to assist you. You may want to edit that.

---

<div class="post-metadata">

**Author:** ![PK1210](https://avatars.discourse-cdn.com/v4/letter/p/8c91f0/32.png) [@PK1210](https://discuss.elastic.co/u/PK1210)\
**Post date:** [December 19, 2018, 1:01pm UTC](https://discuss.elastic.co/t/not-able-to-sort-date/161444/3 "2018-12-19T13:01:51Z")

</div>

Thanks done so

---

<div class="post-metadata">

**Author:** ![rjernst](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/rjernst/32/6363_2.png) [@rjernst](https://discuss.elastic.co/u/rjernst)\
**Post date:** [December 20, 2018, 8:18pm UTC](https://discuss.elastic.co/t/not-able-to-sort-date/161444/4 "2018-12-20T20:18:31Z")

</div>

Your date formats all look basically the same. Regardless, dates sort according to the timeline, not the formatted version of the dates. Could you provide a large example of some string dates you have, and what order you want them to be in when sorting?

---

<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:** [January 17, 2019, 8:18pm UTC](https://discuss.elastic.co/t/not-able-to-sort-date/161444/5 "2019-01-17T20:18:33Z")

</div>

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