5 messages in com.mysql.lists.mysqlRe: Comparing Dates
FromSent OnAttachments
Chad Berryman04 Sep 2001 17:03 
Paul DuBois04 Sep 2001 18:09 
dupon12 Sep 2001 12:19 
Attila Soki12 Sep 2001 12:34 
Adams, Bill TQO12 Sep 2001 12:34 
Subject:Re: Comparing Dates
From:Adams, Bill TQO (bad@tqs.com)
Date:09/12/2001 12:34:31 PM
List:com.mysql.lists.mysql

I have a date comparison problem that I'm sure is simple enough but I'm just not experienced enough to figure it out. I simply want to grab every entry

Um.

First of all, better code would be: my @now = localtime( ); $now[5] += 1900; $now[4] += 1; $currenttime = sprintf( '%04d%02d%02d%02d%02d%02d', @now[5, 4, 3, 2, 1, 0] );

Second, to add/subtract dates in perl and other languages, check out Date::Calc.

Third, in MySQL you cand do something like:

WHERE some_date>DATE_SUB( NOW( ), INTERVAL 5 DAY)

Check out the MySQL manual for more info on DATE_SUB.

--Bill