mysql and DATE format

sp00fD sp00fD at yahoo.com
Wed Nov 24 15:26:52 EST 1999


I've currently got some perl code that executes a sql statment which
looks like:

SELECT id, subject, author, text, DATE_FORMAT(date, \"%W, %d %b %Y\"),
DATE_FORMAT(date, \"%h:%i %p\") FROM Table WHERE thread=18 ORDER by
date desc

When trying to use that in python like this:
"""SELECT .. DATE... FROM %s WHERE thread=%d""" % (table, id)

it tries to expand the DATE %W.. variables.
I've also tried it as

sql = 'SELECT id, subject, author, text, '
sql = sql + 'DATE_FORMAT(date, \"%W, %d %b %Y\"), '
sql = sql + 'DATE_FORMAT(date, \"%h:%i %p\") FROM' + table
sql = sql + 'WHERE thread=' + id + 'ORD...'

which gives me a TypeError: illegal argument type for built-in
operation.  Why?  How can I do this properly?


Sent via Deja.com http://www.deja.com/
Before you buy.




More information about the Python-list mailing list