Re: SELECT
| From: | Adrian Bruce | Date: | Fri, 20 Jan 2006 11:02:01 +0000 |
| Subject: | Re: SELECT | ||
| References: | 1 | Groups: | php.db |
| Request: | Send a blank email to php-db+get-41095@lists.php.net to get a copy of this message | ||
Possibility?
WHERE (
date_created = '$date_90_minutes_ago' AND
time_created <= '$time_90_minutes_ago') or (date_created < '$date_90_minutes_ago' AND
time_created > '01:30:00')
Ade
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 * FROMtableWHEREdate_created<= '$date_90_minutes_ago' ANDtime_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