RE: [PHP] select based on time/date
| From: | Jason Dulberg | Date: | Tue, 25 Sep 2001 22:08:01 +0000 |
| Subject: | RE: [PHP] select based on time/date | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-68781@lists.php.net to get a copy of this message | ||
I tried basically what you have but I got an error:
$sql="select * from logged_in where time_in + interval 1 hour <= now()";
$result = mysql_query($sql);
If it will help, here's the table structure -- looks like my structure is
bit different from what I orignally posted:
CREATE TABLE logged_in (
id tinyint(4) DEFAULT '0' NOT NULL auto_increment,
session varchar(100) DEFAULT '0' NOT NULL,
time_in varchar(50) NOT NULL,
KEY id (id)
);
Thanks again.
__________________
Jason Dulberg
Extreme MTB
http://extreme.nas.net
> 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();
----- 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