# List in order by date

**URL:** <https://www.ruby-forum.com/t/list-in-order-by-date/131577>\
**Category:** Rails\
**Created:** [March 11, 2008, 3:53pm UTC](https://www.ruby-forum.com/t/list-in-order-by-date/131577 "2008-03-11T15:53:45Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![snantz](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/c2a13f/32.png) [@snantz](https://www.ruby-forum.com/u/snantz)\
**Post date:** [March 11, 2008, 3:53pm UTC](https://www.ruby-forum.com/t/list-in-order-by-date/131577/1 "2008-03-11T15:53:45Z")

</div>

I have these entries in the database that have a date field attached to  
them and looks something like:

March 1, 2008  
March 9, 2008  
March 10, 2008

When I do a find and get in oder of ASC it arranges the list as follows:

March 1, 2008  
March 10, 2008  
March 9, 2008

Is there a way to get it to display the list in the correct way?

March 1, 2008  
March 9, 2008,  
March 10, 2008

---

<div class="post-metadata">

**Author:** ![snantz](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/c2a13f/32.png) [@snantz](https://www.ruby-forum.com/u/snantz)\
**Post date:** [March 11, 2008, 6:28pm UTC](https://www.ruby-forum.com/t/list-in-order-by-date/131577/2 "2008-03-11T18:28:09Z")

</div>

Shandy N. wrote:

> March 10, 2008  
> March 9, 2008
> 
> Is there a way to get it to display the list in the correct way?
> 
> March 1, 2008  
> March 9, 2008,  
> March 10, 2008

It sounds to me like you’re storing those as a formatted string, not as  
a datetime object. If you set the table column type to :datetime and  
store the actual date, rather than a string, sorting with ASC should  
work. Then, format the date however you like in the view. Use a helper  
for consistent formatting if displaying the date in multiple places.

–  
[http://www.5valleys.com/](http://www.5valleys.com/)  
[http://www.workingwithrails.com/person/8078](http://www.workingwithrails.com/person/8078)
