date format

Tim Chase python.list at tim.thechases.com
Wed Jan 21 15:42:28 EST 2009


Ahmed, Shakir wrote:
> I am grabbing few fields from a table and one of the columns is in date
> format. The output which I am getting is "Wed Feb 09 00:00:00 2005" but
> the data in that column is "02/09/2005" and I need the same format
> output to insert those recodes into another table.
> 
> print my_service_DATE
> Wed Feb 09 00:00:00 2005

if you are getting actual date/datetime objects, just use the 
strftime() method to format as you so desire.

If you're getting back a *string*, then you should use 
time.strptime() to parse the string into a time-object, and then 
use the constituent parts to reformat as you see fit.

-tkc





More information about the Python-list mailing list