SELECT
am 20.01.2006 12:00:33 von Ron Piggott
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
--
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php
Re: SELECT
am 20.01.2006 12:02:01 von Adrian Bruce
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 * 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
>
>
>
--
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php
Re: SELECT
am 20.01.2006 12:52:17 von robleyd
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
RE: SELECT
am 20.01.2006 15:03:20 von Bastien Koert
Convert both to unix timestamps...be much easier to wrok with both date and
time then
bastien
>From: "Ron Piggott (PHP)"
>Reply-To: ron.php@actsministries.org
>To: PHP DB
>Subject: [PHP-DB] SELECT
>Date: Fri, 20 Jan 2006 06:00:33 -0500
>
>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
>
>--
>PHP Database Mailing List (http://www.php.net/)
>To unsubscribe, visit: http://www.php.net/unsub.php
>
--
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php