Re: SELECT

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Ron Piggott (PHP wrote:

> Yesterday I asked how to get the date & time 90 minutes ago and I
> received several responses.  Thanks.
> 
> I don't think this select statement is working "correctly".  (Correctly
> being what I am intending it to do)
> 
> I took a look at the table this morning.  One record remains that was
> created 2006-01-19 at 23:55:37.  These are the values of date_created
> and time_created.  The current values are approximately 2006-01-20 and
> 05:50:00
> 
> This is the select statement I am writing about:
> 
> SELECT * FROM `table` WHERE `date_created` <= '$date_90_minutes_ago' AND
> `time_created` <= '$time_90_minutes_ago'
> 
> Intellectually I know the problem: 05:50:00 is much earlier than
> 23:55:37 ... thus my AND is not allowing both conditions to exist
> together.
> 
> Is there a way that I may modify this SELECT statement so the present
> conditions continue to exist and add a second part to the SELECT
> statement that if the time is 01:30:00 or higher that records from the
> previous day are selected?  This continues to allow the 90 minute time
> frame for users logged into my web site ... I am not sure how you would
> add an OR function to the above without messing up what presently
> works :)
> 
> (I am writing a SESSION function for my web site using mySQL and a cron.
> The select statement I quoted above is part of the cron.)
> 
> Ron

It would seem you have different columns for date and time? Seems to me that
a little judicious use of CONCAT and DATE_SUB might solve your problem. In
other words, create a valid date/timestamp value with CONCAT then use
DATE_SUB to determine -90 min.

I've given a Mysql based solution as this is php.db :-)



Cheers
-- 
David Robley

"I'm an ordained minister," said Tom reverently.

-- 
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[Index of Archives]     [PHP Home]     [PHP Users]     [Postgresql Discussion]     [Kernel Newbies]     [Postgresql]     [Yosemite News]

  Powered by Linux