On Jan 16, 2012, at 8:34 PM, Mason wrote: > Hi > > I have the following statement > > rows = self.session.query(e.src_id, e.tar_id, \ > e.type, m.text, e.event_ts).\ > outerjoin(m, e.media_id==m.message_id).\ > filter(e.src_id==src_id).\ > filter(e.tar_id==tar_id).\ > all()[start:offset] > > Some of the results are like > > (2L, 1L, 3, None, datetime.datetime(2012, 1, 13, 14, 52, 58)) > (2L, 1L, 3, None, datetime.datetime(2012, 1, 13, 14, 52, 58)) > (2L, 1L, 5, None, datetime.datetime(2012, 1, 13, 14, 52, 59)) > > event_ts is a Datetime object. Is it possible to convert this to utc > in the statement? I can do this directly with the mysql select > statement, but not sure about if this is possible in sqlalchemy
you'd need to use func.<something that does utc>(date), let's check mysql's docs... convert_tz: http://dev.mysql.com/doc/refman/5.5/en/date-and-time-functions.html#function_convert-tz so from sqlalchemy import func session.query(func.convert_tz(e.event_ts, 'EST', 'UTC')) -- You received this message because you are subscribed to the Google Groups "sqlalchemy" group. To post to this group, send email to sqlalchemy@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.