DateTime Format Stuff

pythonhda pythonhda at yahoo.com.replacepythonwithlinux
Tue Dec 31 13:26:19 EST 2002


You could probably get set the format in your SQL instead of python. If all you're doing is getting the date and converting it to a string, you could just have the DB return a nice formatted string for you ie. "November 26, 2000".

 

On Mon, 30 Dec 2002 12:04:58 -0700
Kenneth Godee <Ken at perfect-image.com> wrote:

> I'm pulling a date from a database and is returned as a
> tuple ie....
> 
> (<DateTime object for '2002-11-26 00:00:00.00' at 82237f0>, 99999)
> 
> and I can...
> 
> print rows4[0][0] and get...
> 2002-11-26 00:00:00.00
> 
> or..
> 
> str(rows4[0][0])
> 2002-11-26 00:00:00.00
> 
> My question is what's the easiest way to change 
> the format of the above output from a tuple 
> to something like 11/26/2002.
> I have mxDateTime, time, etc., just can't be as hard
> as I'm making it, All the time modules seem to
> have a lot of functions that work great on system time
> like....
> strftime("%m/%d/%Y", localtime())
> gives me what I want,but won't work on the tuple from
> the database.
> 
> or should I just re the above and custom make my own output?
> Just figured there's some function I'm missing that makes this
> very easy?
> 
> 



More information about the Python-list mailing list