Here's how I would do it. (I'm sure that you'll probably get other solutions as well.)
$query = "SELECT * FROM designs, appliquetable, puffyfoamtable WHERE designs.puffyfoam = puffyfoamtable.puffyfoam AND designs.applique = appliquetable.applique AND
TO_DAYS(NOW()) - TO_DAYS(designs.designadddate) <= 14
GROUP BY catcode ORDER BY designfile";
That is unless you are allowing people to enter future dates in the tables. Unless there is a good reason, I generally have error routines prevent future dates into the table.
jeff
At 13:01 -0500 3/3/03, Stitchin' wrote:
I have a column in my mySql database that holds a date that I've added each record called
designadddate
I'm trying to create a filter to only pull up the records that have been added over the last two weeks. This is my code ... I added the echo for the $today and $twoweeksago variables to make sure something was being calculated, they are showing up correct as 2003-03-03 and 2003-02-17 ... but it isn't pulling up any records -- it's not bombing out and giving me the Couldn't execute query message - but I know there's three records that I made sure had dates in between this range. I also tried using BETWEEN and it didn't seem to work either.
$today = date ("Y-m-d"); $twoweeksago = date("Y-m-d",mktime(0,0,0,date(m), date(d)-14, date(Y)));
echo"$today\n"; echo"$twoweeksago\n";
/* Select designs of the given type */ $query = "SELECT * FROM designs, appliquetable, puffyfoamtable WHERE designs.puffyfoam = puffyfoamtable.puffyfoam AND designs.applique = appliquetable.applique AND (designs.designadddate <= $today AND designs.designadddate >= $twoweeksago)GROUP BY catcode ORDER BY designfile"; $result = mysql_query($query) or die ("Couldn't execute query.");
Any help would me much appreciated!
TIA Renee Toth
--------------------------------------------------------------------- Before posting, please check: http://www.mysql.com/manual.php (the manual) http://lists.mysql.com/ (the list archive)
To request this thread, e-mail <[EMAIL PROTECTED]> To unsubscribe, e-mail <[EMAIL PROTECTED]> Trouble unsubscribing? Try: http://lists.mysql.com/php/unsubscribe.php
--
Jeff Shapiro, Colorado Springs, CO, USA
At work I *have* to use a Windows machine, at home I *get* to use a Mac.
--------------------------------------------------------------------- Before posting, please check: http://www.mysql.com/manual.php (the manual) http://lists.mysql.com/ (the list archive)
To request this thread, e-mail <[EMAIL PROTECTED]> To unsubscribe, e-mail <[EMAIL PROTECTED]> Trouble unsubscribing? Try: http://lists.mysql.com/php/unsubscribe.php