Re: Date -1
| From: | Richard Lynch | Date: | Fri, 26 Jan 2001 09:24:15 +0000 |
| Subject: | Re: Date -1 | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-36760@lists.php.net to get a copy of this message | ||
>I am trying to show the records created from the previous day. How can I
make it show the date before today? My date field is like 2001-01-24
16:13:51. Below shows the current day...
>
>
>$FileDate = date ("Y-m-d");
>
>$connection = mysql_connect ("localhost", "*****", "******");
>if ($connection == false){
> echo mysql_errno().": ".mysql_error()."<BR>";
> exit;
>}
>
>$query = "select * from warbirds_db WHERE FileDate LIKE '%$FileDate%' ORDER
BY FileID DESC";
>$result = mysql_db_query ("combatfs", $query);
Might be easier/better to use MySQL's date_add() and/or date_format() or
whatever they called it.
http://mysql.org
You'll just do:
$query = "select ... where date_format("Y-m-d", FileDate) =
date_format("Y-m-d", date_sub(now(), '1 day'))";
Only odds are really got I got the function names/syntax wrong since I don't
use MySQL.
--
Visit the Zend Store at http://www.zend.com/store/
Wanna help me out? Like Music? Buy a CD: http://l-i-e.com/artists.htm
Volunteer a little time: http://chatmusic.com/volunteer.htm