Re: Making several variables into 1 variable

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

 




On Jul 28, 2009, at 9:55 AM, Miller, Terion wrote:




On 7/28/09 8:52 AM, "Ashley Sheridan" <ash@xxxxxxxxxxxxxxxxxxxx> wrote:

On Tue, 2009-07-28 at 06:46 -0700, Miller, Terion wrote:



On 7/28/09 8:44 AM, "Ashley Sheridan" <ash@xxxxxxxxxxxxxxxxxxxx> wrote:

On Tue, 2009-07-28 at 09:42 -0400, Miller, Terion wrote:


On 7/28/09 8:35 AM, "Ashley Sheridan" <ash@xxxxxxxxxxxxxxxxxxxx> wrote:

$pastDays = strtotime("-30 days");
$date = date("d/m/y", $pastDays);

Well I tried and got no results from my query and I know there results with date ranges in the last 30 days, I basically need to count backward from now() 30 days I thought strtotime() would work well..but the fields in the db are varchar not date fields they are all formatted the same though 00/00/00:

$sql = "SELECT DISTINCT restaurants.ID, name, address, inDate FROM restaurants, inspections WHERE restaurants.name != '' AND inspections.inDate <= $date GROUP BY restaurants.ID ORDER BY 'name' ";


I believe the query is suspect. From memory, don't you need to enclose
dates in single quotes in MySQL statements? Also, I believe it uses
American data format, so you might have to put the month before the day
like was in Richards example.

Thanks,
Ash
http://www.ashleysheridan.co.uk



Ah ha bet that's it didn't notice the euro/brit date formatting there. Lol thanks guys!

Euro/Brit date formatting? Nah, it's proper data formatting, not what you crazy Yanks do! ;)


Thanks,
Ash
http://www.ashleysheridan.co.uk

LOL I know we yanks bastardize everything...anyways it still didn't work...argh...so the boss thought he'd give me something harder...lovely, now I have to figure out how to reverse publish things to quark....get ready guys I may be blowing the list up soon with questions (like I don't already)
Terion

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



You can also do this right within MySQL without needing to create a variable. This should work: $sql = "SELECT DISTINCT restaurants.ID, name, address, inDate FROM restaurants, inspections WHERE restaurants.name != '' AND datediff(curdate(),inspections.inDate)>=30 GROUP BY restaurants.ID ORDER BY 'name' ";

Take care,
Floyd


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


[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux