RE: [PHP] Using a query to selecting between two dates
| From: | Don Read | Date: | Sun, 29 Jul 2001 23:02:03 +0000 |
| Subject: | RE: [PHP] Using a query to selecting between two dates | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-60123@lists.php.net to get a copy of this message | ||
On 29-Jul-2001 Mike Gifford wrote:
> Hello,
>
> 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,
--
Don Read dread@texas.net
-- It's always darkest before the dawn. So if you are going to
steal the neighbor's newspaper, that's the time to do it.