Skip to main content
Known Participant
February 6, 2011
Question

Odd issue with WHERE clause

  • February 6, 2011
  • 1 reply
  • 285 views

Greetings All,

I'm having an odd issue with a WHERE clause that I've been working on in a Record Set, $upperdate displays as 2011-02-28, $lowerdate as 2011-02-01, but,

WHERE visitdate >= $lowerdate AND visitdate <= $upperdate

returns no values, and

WHERE visitdate >= $lowerdate AND visitdate <= '2011-02-28'

returns the appropriate values,

Here is the code for $upperdate and $lowerdate:

******************************************
$datemonth = date ('m');
$dateday = '01';
$dateday1 = date ('t');
$dateyear = date ('Y');

$lowerdate = date("Y-m-d",mktime(0,0,0,$datemonth, $dateday, $dateyear));
$upperdate = date("Y-m-d",mktime(0,0,0,$datemonth, $dateday1, $dateyear));
******************************************

I've also tried the following things to check functionality with no success:

$upperdate = '2011-02-28';

$dateday1 = '28';

BETWEEN...AND... behaves the same as... >=  AND <=

Thanks for the help in advance!

This topic has been closed for replies.

1 reply

tim19260Author
Known Participant
February 18, 2011

Finally worked it out,

I ended up putting single parentheses around '$lowerdate' and '$upperdate' and it works now.

It still seems strange, because it worked when I used no parentheses with the variable in:

WHERE visitdate >= $lowerdate AND visitdate <= '2011-02-28'

Also, I had tried the parentheses a few other times without success, so maybe there was something else awry that I fixed inadvertantly while messing around.

Tim