convert date time

D'Arcy J.M. Cain darcy at
Fri Aug 21 21:42:27 CEST 2009

On Fri, 21 Aug 2009 14:43:55 -0400
Ronn Ross <ronn.ross at> wrote:
> On Fri, Aug 21, 2009 at 2:26 PM, D'Arcy J.M. Cain <darcy at> wrote:
> > You don't say what database you are using but you may find it simpler
> > to do the conversion in your SELECT statement.  For example, see
> > for
> > PostgreSQL formatting functions.
> >
> I apologize I should have made it clear that this date is stored in the db
> as a string/varchar. The reason it is stored that way is before it's being
> read in from a text file where it is formatted that way.

You can still save it as a timestamp:

SELECT '8/2/2009 8:36:16 AM (UTC)'::timestamp(0);
 2009-08-02 08:36:16
(1 row)

Your input format is read into PostgreSQL time types directly.  Same
may be true of other databases.

D'Arcy J.M. Cain <darcy at>         |  Democracy is three wolves                |  and a sheep voting on
+1 416 425 1212     (DoD#0082)    (eNTP)   |  what's for dinner.

More information about the Python-list mailing list