php-general Digest 3 Mar 2011 14:17:28 -0000 Issue 7208

Topics (messages 311620 through 311626):

something about dates in mysql
        311620 by: Webforlaget.dk
        311621 by: Richard Quadling
        311622 by: Nathan Rixham
        311623 by: Alex
        311624 by: Gerardo Benitez
        311625 by: Richard Quadling

PHP 5.3.6RC2 Released for Testing
        311626 by: Johannes Schlüter

Administrivia:

To subscribe to the digest, e-mail:
        [email protected]

To unsubscribe from the digest, e-mail:
        [email protected]

To post to the list, e-mail:
        [email protected]


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

--- End Message ---
--- Begin Message ---
On 3 March 2011 10:09, Webforlaget.dk <[email protected]> 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

--- End Message ---
--- Begin Message ---
Richard Quadling wrote:
On 3 March 2011 10:09, Webforlaget.dk <[email protected]> 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.

yes, and remember the DATE and FROM_UNIXTIME mysql functions too.

--- End Message ---
--- Begin Message ---
Just a correction, dates in mysql are not strings by any means, they are stored 
in 3 bytes (date and time or 8 bytes for datetime) and that's nowhere enough 
for a string, however the representation of the date is a formatted string, so 
for all intents and purposes any comparison to a date field should be using 
quotes like mentioned already. 
-- 
Sent from my Android phone with K-9 Mail. Please excuse my brevity.

Nathan Rixham <[email protected]> wrote:

Richard Quadling wrote: > On 3 March 2011 10:09, Webforlaget.dk 
<[email protected]> 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. yes, and remember the DATE and 
>> >> FROM_UNIXTIME mysql functions too. -- PHP General Mailing List 
>> >> (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php 


--- End Message ---
--- Begin Message ---
Hi Webforlaget!

$thisdate is today?

$today = date('Y-m-d");

else

why, you dont use $thisdate as:
$thisdate = "$year-$mth-$day" ?

use quotes for $thisdate in sql query.

Regards.
Gerardo


On Thu, Mar 3, 2011 at 7:09 AM, Webforlaget.dk <[email protected]> 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




-- 
Gerardo Benitez
-------------------------
www.webseficientes.com.ar
Diseño web, programación, Seo

--- End Message ---
--- Begin Message ---
On 3 March 2011 12:33, Alex <[email protected]> wrote:
> Just a correction, dates in mysql are not strings by any means, they are 
> stored in 3 bytes (date and time or 8 bytes for datetime) and that's nowhere 
> enough for a string, however the representation of the date is a formatted 
> string, so for all intents and purposes any comparison to a date field should 
> be using quotes like mentioned already.
> --
> Sent from my Android phone with K-9 Mail. Please excuse my brevity.
>
> Nathan Rixham <[email protected]> wrote:
>
> Richard Quadling wrote: > On 3 March 2011 10:09, Webforlaget.dk 
> <[email protected]> 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. yes, and remember the DATE 
>>> >> and FROM_UNIXTIME mysql functions too. -- PHP General Mailing List 
>>> >> (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
>
>

I didn't intend to suggest that dates in mysql were STORED as strings,
just that in the SQL Statement they were treated as strings.



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

--- End Message ---
--- Begin Message ---
The second release candidates of 5.3.6 was just released for testing and
can be downloaded here:

http://downloads.php.net/johannes/php-5.3.6RC2.tar.bz2 (md5sum:
f870685b8715600e056d2dbb22920576)
http://downloads.php.net/johannes/php-5.3.6RC2.tar.gz (md5sum:
32e88f8a2dd1e756d386b7fe625c7e8b)

The windows binaries are available at: http://windows.php.net/qa/
Windows users please mind that we don't provide VS6 builds anymore.

This is a step in the release process of this versions and goal
is having a final version by next week. Majority of the changes are of
the "bug fix" variety. To ensure that the release is solid, please test
this RC against your code base and report any problems that you
encounter.

Johannes Schlüter
PHP 5.3 Release Master



--- End Message ---

Reply via email to