Bookmarks

Yahoo Gmail Google Facebook Delicious Twitter Reddit Stumpleupon Myspace Digg

Search queries

Catastrophic failure Unexpected method call sequence. 0x8000ffff (-2147418113)., ksh lock a file, [unixODBC][Driver Manager]Driver's SQLAllocHandle on SQL_HANDLE_DBC failed, sed: -e expression #1, char 1: unterminated address regex, procmail + change subject, w2ksp4.exe download, /proc/kallsyms format, sqldatasource dal, wwwxxxenden, convert raid5 to raid 10 mdadm

Links

XODOX
Impressum

#1: CURDATE()

Posted on 2011-08-18 09:15:36 by ron.piggott

------=_NextPart_000_0140_01CC5D55.195B9F20
Content-Type: text/plain;
charset="utf-8"
Content-Transfer-Encoding: quoted-printable


I am setting up a daily cron job to update the site map on my web site. =


I want to delete any records that werenâÂ=99t updated by the cron =
job each day. The way I can distinguish this is with the timestamp =
column named âÂ=9Clast_record_updateâÂ=9D If a record =
wasnâÂ=99t updated it is no longer part of the web site.=20

I am trying to figure out if there is a way for me to use =
mysqlâÂ=99s date functions to query the records that are no longer =
part of the web site.

What I tried below doesnâÂ=99t work: ( CURDATE() . % )

The reason I wanted to use % is because the time will follow the date in =
a âÂ=9CtimestampâÂ=9D column

Is there a similar way to do what I am trying:

SELECT `reference` FROM `sitemap_pages` WHERE `last_record_update` NOT =
LIKE ( CURDATE() . % ) ORDER BY `reference` +0

Thanks for helping. =20

Ron

The Verse of the Day
âÂ=9CEncouragement from GodâÂ=99s WordâÂ=9D
http://www.TheVerseOfTheDay.info =20

------=_NextPart_000_0140_01CC5D55.195B9F20--

Report this message

#2: Re: CURDATE()

Posted on 2011-08-18 11:21:22 by Geoff Lane

On Thursday, August 18, 2011, Ron Piggott wrote;

> What I tried below doesn=92t work: ( CURDATE() . % )

Even though date values are presented like strings, they are
dates/times. So you need to either cast CURDATE() to a string or else
perform 'date arithmetic'. Check the manual for DATEDIFF(), CAST(),
and CONVERT().

> NOT LIKE ( CURDATE() . % )

I suspect that PHP's concatenation operator (the period) isn't
recognised by MySQL (assuming that's the DB you're using). So you need
to either use MySQL's CONCAT() function or else create the search
string in PHP rather than MySQL. However, if you're going to do this,
you need to also cast last_record_update to a string.

Personally, I'd use:
WHERE DATEDIFF(CURDATE(), last_record_update) > 1
(testing for 1 rather than 0 just in case the date rolled over between
the update and the 'stale record' check.)

HTH,

--=20
Geoff


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

Report this message

#3: Re: CURDATE()

Posted on 2011-08-20 07:21:28 by win.acc

--20cf305b13389c61ac04aae904ef
Content-Type: text/plain; charset=UTF-8

I tried on my db
"select count(*) from my_table where col_timestamp<curdate();"
the column col_timestamp type is timestamp,this sql works well.
hope it helpful.

All you best
------------------------
What we are struggling for ?
The life or the life ?



On Thu, Aug 18, 2011 at 5:21 PM, Geoff Lane <geoff@gjctech.co.uk> wrote:

> On Thursday, August 18, 2011, Ron Piggott wrote;
>
> > What I tried below doesn t work: ( CURDATE() . % )
>
> Even though date values are presented like strings, they are
> dates/times. So you need to either cast CURDATE() to a string or else
> perform 'date arithmetic'. Check the manual for DATEDIFF(), CAST(),
> and CONVERT().
>
> > NOT LIKE ( CURDATE() . % )
>
> I suspect that PHP's concatenation operator (the period) isn't
> recognised by MySQL (assuming that's the DB you're using). So you need
> to either use MySQL's CONCAT() function or else create the search
> string in PHP rather than MySQL. However, if you're going to do this,
> you need to also cast last_record_update to a string.
>
> Personally, I'd use:
> WHERE DATEDIFF(CURDATE(), last_record_update) > 1
> (testing for 1 rather than 0 just in case the date rolled over between
> the update and the 'stale record' check.)
>
> HTH,
>
> --
> Geoff
>
>
> --
> PHP Database Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>

--20cf305b13389c61ac04aae904ef--

Report this message