Exit
  • Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers
0

Odd issue with WHERE clause

New Here ,
Feb 06, 2011 Feb 06, 2011

Copy link to clipboard

Copied

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!

TOPICS
Server side applications

Views

257
Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Feb 18, 2011 Feb 18, 2011

Copy link to clipboard

Copied

LATEST

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

Votes

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines