Re: Dates in MYSQL

From: Date: Wed, 17 Apr 2002 16:35:53 +0000
Subject: Re: Dates in MYSQL
References: 1  Groups: php.db 
Request: Send a blank email to php-db+get-18607@lists.php.net to get a copy of this message
Hi Alex, > Got my select statement to work as follows: > $query = ' SELECT * FROM notices WHERE TO_DAYS(eventdate) >= TO_DAYS(now()) > order by eventdate'; =well done! However the TO-DAYS calls do seem a bit OTT. Please post the schema for tbl:notices - specifically the datatype for eventdate. > Now trying to get the date more user friendly and tried: > > $query = ' SELECT id, eventheading, DATE_FORMAT("eventdate", "%D %M %Y")FROM > notices WHERE TO_DAYS(eventdate) >= TO_DAYS(now()) order by eventdate'; ... > When I echo ($eventdate) I get nothing. Not even an error. The problem is that $eventdate = "$row[eventdate]"; (which doesn't need the " around the whole of the RHS (some would put them around eventdate), BTW) doesn't tie up with: DATE_FORMAT("eventdate", "%D %M %Y") Recommend you change them to: DATE_FORMAT("eventdate", "%D %M %Y") AS evdt and $eventdate = $row[evdt]; See how the SQL and PHP tie together? Now you need to reconsider the other $row[] assignments. =Keep it coming! =dn

« previous php.db (#18607) next »