[DB-SIG] Date/Time in MySQL
Andy Dustman
andy@dustman.net
11 Dec 2001 15:29:56 -0500
On Tue, 2001-12-11 at 08:34, Lindstrom Greg - glinds wrote:
> I am now using mySQL as my database so I have access to Date/Time data. I
> have created a database and have access methods, but would like to know how
> to create a Select to fetch all dates in a given range. I have tried just
> about everything I can think of. Could one of you show me how to do this?
One thing to watch out for with MySQLdb is due to the fact that it uses
format codes (i.e. %s) for parameter placeholders. Because of this, if
you need a literal % in your SQL, you need to double it (%%). This isn't
really documented, and I should fix that... David's example looks okay,
and you don't need to %% there because it is doing parameter
substitution. But supposing you used the LIKE operator against a literal
string in your query, and you are using % as the wildcard match, that %
you would have to double. If you are passing in a string literal with a
% as a parameter, don't worry about it, because it can't be interpreted
as a format code.
--
Andy Dustman PGP: 0x930B8AB6
@ .net http://dustman.net/andy
You can have my keys when you pry them from my dead, cold neurons.