Re: Date question

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



I have a datetime column in MySQL DB. How can I match to that column from php code if I only have the date information available.
2006-02-24 12:00:00  against    2006-02-24
This might be more SQL question sorry about that.
use date_format("%Y-%m-%d",'date_column') in the sql
http://dev.mysql.com/doc/refman/5.0/en/date-and-time-functions.html

The above is likely one of the more elegant solutions. But if you wanted to do this
completely in PHP, you could do something like:

<pseudocode>

 $phpDate = '2006-02-24';

 $rowData = mysql_fetch_assoc( $yourQuery );

 if( date( 'Y-m-d', strtotime( $rowData['MySQLDate'] )) == $phpDate )) {
   echo 'Dates match!';

 }
</pseudocode>

thnx,
Chris
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux