Re: date problems

From: Date: Thu, 06 Sep 2007 18:59:13 +0000
Subject: Re: date problems
References: 1 2  Groups: php.db 
Request: Send a blank email to php-db+get-43970@lists.php.net to get a copy of this message
Argh, make sure you add the closing paren for the date_add since I forgot it. Mike... Mike Gohlke wrote:
It's much better to use add_date instead of to_days since mysql isn't smart enough to do it for you. Such as: SELECT yourEventFields FROM theTable WHERE theEventDate BETWEEN now() AND date_add(now(), INTERVAL 21 DAYS; This way mysql will calc the now() and date_add and will essentially convert them to static values. If there's an index on theEventDate it will be used. Mike... Instruct ICC wrote:
From: rDubya <ryan.dubya@gmail.com> My problem is that I have events dated for Sep 2007 and on, and yet they all come up as being on Dec 7 to 9, 2006.. any ideas? rDubya
How about having MySQL only return the events you are interested in? SELECT yourEventFields FROM theTable WHERE TO_DAYS( theEventDate ) >= TO_DAYS( NOW() ) AND TO_DAYS( theEventDate ) <= TO_DAYS( NOW() ) + 21 I like theEventDate to be in the format YYYY-MM-DD http://dev.mysql.com/doc/refman/5.0/en/date-and-time-functions.html#function_to-days _________________________________________________________________ A place for moms to take a break! http://www.reallivemoms.com?ocid=TXT_TAGHM&loc=us


« previous php.db (#43970) next »