RE: [PHP-DB] Re: Query and Date problem

2001-08-15 Thread Jeff Oien

> "Jeff Oien" <[EMAIL PROTECTED]> wrote in message
> [EMAIL PROTECTED]">news:[EMAIL PROTECTED]...
> > I want to retrieve the last 15 days of data from a certain time but
> > not today's. I have this but it's still giving me today's data:
> >
> > $today = date("Y-m-d");
> > $sql = "SELECT volume, date, time, id
> > FROM $table_name
> > where time = $time1 and date != $today ORDER by id desc LIMIT 15";
> >
> > (date != $today) code in question
> >
> > When I print $today it's: 2001-08-15 and the date field in the database
> > is also displaying as 2001-08-15. Any suggestions? Thanks in advance.
> > Jeff Oien
> 
> ... I would not depend on id being monotonic
> (it probably will be, but I would still not
> depend on it).
> 
> How 'bout
> 
> SELECT volume,date,time,id
> FROM $table
> WHERE time=$time1
> ORDER BY date DESC
> LIMIT 1,15
> 
> What are you storing time as - a timestamp
> rounded down to the last half-hour?

That works also, thanks. The cron job runs on the half hour so the
timestamp is always HH00 or HH30. I check to see what time it is
now and then finds the data from the same half hour time period for
the last 15 days.
Jeff Oien 

-- 
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




[PHP-DB] Re: Query and Date problem

2001-08-15 Thread Hugh Bothwell


"Jeff Oien" <[EMAIL PROTECTED]> wrote in message
[EMAIL PROTECTED]">news:[EMAIL PROTECTED]...
> I want to retrieve the last 15 days of data from a certain time but
> not today's. I have this but it's still giving me today's data:
>
> $today = date("Y-m-d");
> $sql = "SELECT volume, date, time, id
> FROM $table_name
> where time = $time1 and date != $today ORDER by id desc LIMIT 15";
>
> (date != $today) code in question
>
> When I print $today it's: 2001-08-15 and the date field in the database
> is also displaying as 2001-08-15. Any suggestions? Thanks in advance.
> Jeff Oien

... I would not depend on id being monotonic
(it probably will be, but I would still not
depend on it).

How 'bout

SELECT volume,date,time,id
FROM $table
WHERE time=$time1
ORDER BY date DESC
LIMIT 1,15

What are you storing time as - a timestamp
rounded down to the last half-hour?



-- 
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]