# Date field is sorted like text and not date in backend

**URL:** <https://discourse.getcockpit.com/t/date-field-is-sorted-like-text-and-not-date-in-backend/1924>\
**Category:** Support\
**Created:** [April 28, 2021, 1:44pm UTC](https://discourse.getcockpit.com/t/date-field-is-sorted-like-text-and-not-date-in-backend/1924 "2021-04-28T13:44:24Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![BenOlv](https://avatars.discourse-cdn.com/v4/letter/b/50afbb/32.png) [@BenOlv](https://discourse.getcockpit.com/u/BenOlv)\
**Post date:** [April 28, 2021, 1:44pm UTC](https://discourse.getcockpit.com/t/date-field-is-sorted-like-text-and-not-date-in-backend/1924/1 "2021-04-28T13:44:24Z")

</div>

Hi !  
I have a date field named “checkin\_date” set up like this :

{  
“weekstart”: 1,  
“format”: “DD-MM-YYYY” /\* Europe format \*/  
}  
I use this field to sort bookings by their arrival  
Unfortunately, when I want to sort my entries in the backend, it’s not sorted like date but more like text.

Sorted desc give me this :

30-04-2021  
21-05-2021  
14-05-2021  
07-05-2021

But I need the dates to be sorted chronologically like this :

30-04-2021  
07-05-2021  
14-05-2021  
21-05-2021

Is there a way to achieve this with the field options ? Did I missed something ?  
Since it’s a date field I thought it would have been sorted like dates.  
I’ve looked everywhere, did not found anything about it.

Thanks !

---

<div class="post-metadata">

**Author:** ![maettyhawk](https://yyz2.discourse-cdn.com/flex030/user_avatar/discourse.getcockpit.com/maettyhawk/32/1065_2.png) [@maettyhawk](https://discourse.getcockpit.com/u/maettyhawk)\
**Post date:** [March 15, 2022, 5:09pm UTC](https://discourse.getcockpit.com/t/date-field-is-sorted-like-text-and-not-date-in-backend/1924/2 "2022-03-15T17:09:47Z")

</div>

I’ve got pretty much the same problem… even changing the format to “YYYY-MM-DD” won’t change anything, because it doesn’t affect the already saved entries.

---

<div class="post-metadata">

**Author:** ![serjoscha87](https://yyz2.discourse-cdn.com/flex030/user_avatar/discourse.getcockpit.com/serjoscha87/32/151_2.png) [@serjoscha87](https://discourse.getcockpit.com/u/serjoscha87)\
**Post date:** [March 22, 2022, 7:07pm UTC](https://discourse.getcockpit.com/t/date-field-is-sorted-like-text-and-not-date-in-backend/1924/3 "2022-03-22T19:07:32Z")

</div>

cockpit has no dedicated sorting for dates - you have to use the format YYYY-MM-DD or process/re-order the dates your self (which is quite easy with php / js but of course needs some extre performance instead of directly getting data in the right order)
