Get yesterday's date

Cliff Wells LogiplexSoftware at earthlink.net
Wed Nov 27 12:44:43 EST 2002


On Wed, 2002-11-27 at 02:15, Michel COMBE wrote:
> Hi,
> 
> I need to run a SQL query on a MySQL database to get yesterday's records.
> How do I specify "yesterday" ?
> Isn't there some kind of date arithmetic in Python or should I use an
> external library ?
> Which library ?

Why not just use MySQL's built in date/time functions?

SELECT * FROM mytable WHERE TO_DAYS(mydatefield) = TO_DAYS(NOW() -
INTERVAL 1 DAY);

Haven't used MySQL in a while, but I think this (or something similar)
should work.


-- 
Cliff Wells, Software Engineer
Logiplex Corporation (www.logiplex.net)
(503) 978-6726 x308  (800) 735-0555 x308
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 196 bytes
Desc: This is a digitally signed message part
URL: <http://mail.python.org/pipermail/python-list/attachments/20021127/f0b5848a/attachment.sig>


More information about the Python-list mailing list