you'd need to use SQL functions that break the datetime into its component 
parts, and order by them.

such as:

order_by(func.datepart("MONTH", my_date_col), func.datepart("DAY", 
my_date_col), func.datepart("YEAR", my_date_col))

"datepart" routines vary by database backend with very little cross 
compatibility - you'd have to consult the documentation for your database on 
the recommended way to break dates up into components.


On Jan 10, 2011, at 5:35 AM, F.A.Pinkse wrote:

> Hi All.
> 
> 
> I have a datetime column in my model.
> 
> If I do an .order_by I get year-month-day
> 
> but how do I do an order_by to get month-day-year?
> 
> or even a day-month-year
> 
> 
> Thanks,
> 
> 
> Frans.
> 
> -- 
> You received this message because you are subscribed to the Google Groups 
> "sqlalchemy" group.
> To post to this group, send email to sqlalch...@googlegroups.com.
> To unsubscribe from this group, send email to 
> sqlalchemy+unsubscr...@googlegroups.com.
> For more options, visit this group at 
> http://groups.google.com/group/sqlalchemy?hl=en.
> 

-- 
You received this message because you are subscribed to the Google Groups 
"sqlalchemy" group.
To post to this group, send email to sqlalch...@googlegroups.com.
To unsubscribe from this group, send email to 
sqlalchemy+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/sqlalchemy?hl=en.

Reply via email to