Re: MySQL datetime fields

From: Date: Wed, 06 Sep 2000 08:17:16 +0000
Subject: Re: MySQL datetime fields
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-15464@lists.php.net to get a copy of this message
On Wed, 06 Sep 2000, Jason Murray wrote: > Hi folks, > > Apologies for the OT post, but this is a quickie, and I'm desperate, > and I've tried to help here before :) > > I have a 'datetime' field in a MySQL table. It is populated with an > "UPDATE table SET field = NOW() WHERE ID = $thisid" command when an > order is complete. > > I'd like to know the SELECT syntax so that I could select all the rows > from 'table' where 'field' has not been set (in which case it'll be > '0000-00-00 00:00:00'). > > Problem is, "SELECT * FROM table WHERE field = '0000-00-00 00:00:00'" > *still* returns this row. For now I'm having PHP do an absolute check > on the value before I output, and I'm silently ignoring it if its not > all zero's. > > Can anyone help me with this please? I'd rather not 'code around' it > this way with PHP, I'd rather get the correct results from MySQL... > > Jason > > -- > Jason Murray > jasonm@melbourneit.com.au > Web Design Team, Melbourne IT > Don't believe everything you're foretold. Wild guess time - maybe where the field has not been set you need to check for a NULL value; probably mysql is happily formatting the NULL value to zeros as it hands it to you. I could be wrong, of course.... -- David Robley | WEBMASTER & Mail List Admin RESEARCH CENTRE FOR INJURY STUDIES | http://www.nisu.flinders.edu.au/ AusEinet | http://auseinet.flinders.edu.au/ Flinders University, ADELAIDE, SOUTH AUSTRALIA

« previous php.general (#15464) next »