Re: something about dates in mysql

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

 



On 3 March 2011 10:09, Webforlaget.dk <info@xxxxxxxxxxxxxxx> wrote:
> I need help to know Why this dont work ?
>
> -------------------------------------------------------------
>
> Â$thisdate =date("Y-m-d",mktime(0,0,0,$mth, $day, $year));
>
> Â$sql Â= "SELECT id,case,startdate,enddate FROM table WHERE startdate<=$thisdate AND enddate>=$thisdate ORDER BY startdate";
>
> -------------------------------------------------------------
>
> The result should be an array whith open cases at $thisdate, but nothing appear.
>
> Is it something about dates in mysql ?
>
> Thanks for any advice.
>
> Best regards,
>
> Venlige hilsner
>
> Rolf Brejner

I think that dates in SQL statements need to be in the quotes as they
are strings and not integers.

So, try ...

$sql  = "SELECT id,case,startdate,enddate FROM table WHERE
startdate<='$thisdate' AND enddate>='$thisdate' ORDER BY startdate";

I'm surprised you don't get an error....

Ah. As it stands, the SQL is something like ...

WHERE startdate <= 2010 - 3 - 3

So, probably the actual test that is being executed is ....

WHERE startdate <= 2004

Which, for a date stamp will never return anything sensible.

Regards,

Richard.

-- 
Richard Quadling
Twitter : EE : Zend
@RQuadling : e-e.com/M_248814.html : bit.ly/9O8vFY

-- 
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