Re: select based on time/date
| From: | Sheridan Saint-Michel | Date: | Tue, 25 Sep 2001 21:44:27 +0000 |
| Subject: | Re: select based on time/date | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-68779@lists.php.net to get a copy of this message | ||
----- Original Message -----
From: "Jason Dulberg" <jdulberg@nas.net>
To: <huntsman@www.nisu.flinders.edu.au>; <php-general@lists.php.net>
Sent: Tuesday, September 25, 2001 2:35 PM
Subject: RE: [PHP] select based on time/date
> I had a look at the DATE_FORMAT info on the mysql doc page and its a bit
> easier to understand than the CONCATS.
>
> Would I want to use the CURTIME() function since I would want to select
> sessions based on the hour? How would I go about combining CURTIME with
the
> rest of my query?
>
> Theoretically, here is what I understand, please let me know whether or
not
> I am correct:
>
> select * from sessions where (CURTIME() - EXTRACT(MINUTE FROM $timein) >=
> 60);
> //where 60 is the lifespan of the session
The problem with this is curtime returns a number in HHMMSS format and your
extract
returns MM so you get HHMMSS - MM which is always going to be greater than
60
unless you are running your script in the first minute of the day (ie
000037 - 49).
Try this instead:
select * from sessions where $timein + interval 1 hour <= now();
> Thanks for your suggestions and time!
>
> __________________
> Jason Dulberg
> Extreme MTB
> http://extreme.nas.net
No Problem... hope that helps
Sheridan Saint-Michel
Website Administrator
FoxJet, an ITW Company
www.foxjet.com