Re: Using a query to selecting between two dates
| From: | Mike Gifford | Date: | Mon, 30 Jul 2001 22:16:35 +0000 |
| Subject: | Re: Using a query to selecting between two dates | ||
| References: | 1 2 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-60283@lists.php.net to get a copy of this message | ||
I ended up using your simpler version, which came out like this:
$contentquery3 = mysql_query("SELECT *, YEAR(date) AS year, YEAR(NOW()) AS now FROM $articlestable WHERE articleSectionID = '$id' AND YEAR(date) = YEAR(NOW()) ORDER BY date DESC") or mysql_die();
Thanks.
Mike
Don Read wrote:
On 29-Jul-2001 Mike Gifford wrote:-- Mike Gifford, OpenConcept Consulting, http://openconcept.ca Offering everything your organization needs for an effective web site. Abolish Nuclear Weapons Now!: http://pgs.ca/petition/ It is a miracle that curiosity survives formal education. - A EinsteinHello, I've got a number of press releases that I'd like to be able to order by year. I'd like everything from this now to a year ago (ie. July 29th, 2000) to be ordered together and then allow folks to scroll back to the previous year July 30, 2000 to July 29th, 1999, etc.Sounds like a confusing interface to me. how about selecting by numerical year ? if (! isset($wantyear))$wantyear=date('Y');SELECT ... WHERE YEAR(date)='$wantyear' ... If you insist on now() - 1 year, look into DATE_SUB(NOW(), INTERVAL 1 YEAR) Regards,