Re: [Tutor] date conversion

2006-04-05 Thread Kent Johnson
Python wrote: > On Wed, 2006-04-05 at 10:50 -0400, Kent Johnson wrote: >> Ray Allen wrote: >>> I would like Python to convert a date returned by MySQL (2006-04-05) > > Kent's advice below is of course correct, but I'd bet your variable is > already a datetime.date (or mx.DateTime.Date with older P

Re: [Tutor] date conversion

2006-04-05 Thread Python
On Wed, 2006-04-05 at 10:50 -0400, Kent Johnson wrote: > Ray Allen wrote: > > I would like Python to convert a date returned by MySQL (2006-04-05) Kent's advice below is of course correct, but I'd bet your variable is already a datetime.date (or mx.DateTime.Date with older Python releases). In th

Re: [Tutor] date conversion

2006-04-05 Thread Brian Gustin
Oh yeah - you can also simply use Mysql's date_format() function when you query the database ?? select date_format(column_name,'%d-%b-%Y') as formatted_date from table where blah; would output the date as 05-Apr-2006 http://dev.mysql.com/doc/refman/4.1/en/date-and-time-functions.html Brian

Re: [Tutor] date conversion

2006-04-05 Thread Brian Gustin
I wrote something similar on my blog some time back.. http://phplogix.com/codefool/?postid=13 This is for converting Apache logfiles to a ISO formatted date for mysql.. It could easily be reversed, with a little tweaking.. :) to wit: def mreplace(s, chararray, newchararray): for a, b in zip

Re: [Tutor] date conversion

2006-04-05 Thread Kent Johnson
Ray Allen wrote: > I would like Python to convert a date returned by MySQL (2006-04-05) to a > user readable format such as 05-Apr-2006 for display and then to convert it > back to ISO format for update. Here's one way: In [1]: from datetime import date In [2]: data = '2006-04-05' Use split()

[Tutor] date conversion

2006-04-05 Thread Ray Allen
I would like Python to convert a date returned by MySQL (2006-04-05) to a user readable format such as 05-Apr-2006 for display and then to convert it back to ISO format for update. What is the most convenient way of doing this? I'm struggling to understand the datetime module's functionality.