close ad
 
Important WebAssist Announcement
open ad
View Menu

Technical Support Forums

Free, outstanding support from WebAssist and your colleagues

rating

Date Range Search missing 1st day

Thread began 3/03/2011 8:54 pm by enquiry272230 | Last modified 3/05/2011 2:09 am by Dave Buchholz | 2652 views | 8 replies |

enquiry272230

Date Range Search missing 1st day

Hi,

By following various posts and tutorials herein, I have successfully created a search by date range.
I have a recordset to filter the date by the form post, and well as "Greater Than or Equal To" and "Less Than or Equal To" form input boxes.

I am using the datepicker as well

All works really well, but there is a unusual bug.

Whenever I do a date range search, it always misses the oldest day.
It's like the "Equal To" (>=) part is not working.

Any advice is appreciated, cant figure this one - 2 files attached.

Attached Files
Search.zip
Sign in to reply to this post

Dave BuchholzBeta Tester

To successfully achieve this you need to choose Date Range from within the search wizard



and then specify your fields



Note: my db field will be different to yours as I am using one of my existing sites.

this will give you this code block

php:
<?php

//WA Database Search (Copyright 2005, WebAssist.com)
//Recordset: WADAvisitors;
//Searchpage: visitors_Search.php;
//Form: WADASearchForm;
$WADbSearch1_DefaultWhere "";
if (!
session_id()) session_start();
if ((isset(
$_GET["Search_x"]) && $_GET["Search_x"] != "")) {
  
$WADbSearch1 = new FilterDef;
  
$WADbSearch1->initializeQueryBuilder("MYSQL","1");
  
//keyword array declarations

  //comparison list additions
  
$WADbSearch1->addComparisonFromEdit("VisitorID","S_VisitorID","AND","=",1);
  
$WADbSearch1->addComparisonFromEdit("VisitorUserName","S_VisitorUserName","AND","Includes",0);
  
$WADbSearch1->addComparisonFromEdit("VisitorPassword","S_VisitorPassword","AND","Includes",0);
  
$WADbSearch1->addComparisonFromEdit("VisitorEmail","S_VisitorEmail","AND","Includes",0);
  
$WADbSearch1->addComparisonFromList("VisitorDate","S_VisitorDate","AND",">=",2);
  
$WADbSearch1->addComparison("VisitorDate","".WAQB_getEndDate($_POST["E_VisitorDate"])  ."","AND","<=",2);
  
$WADbSearch1->addComparisonFromEdit("VisitorFirstName","S_VisitorFirstName","AND","Includes",0);
  
$WADbSearch1->addComparisonFromEdit("VisitorLastName","S_VisitorLastName","AND","Includes",0);
  
$WADbSearch1->addComparisonFromEdit("VisitorBillName","S_VisitorBillName","AND","Includes",0);
  
$WADbSearch1->addComparisonFromEdit("VisitorBillAddress1","S_VisitorBillAddress1","AND","Includes",0);
  
$WADbSearch1->addComparisonFromEdit("VisitorBillAddress2","S_VisitorBillAddress2","AND","Includes",0);
  
$WADbSearch1->addComparisonFromEdit("VisitorBillCity","S_VisitorBillCity","AND","Includes",0);
  
$WADbSearch1->addComparisonFromEdit("VisitorBillStateID","S_VisitorBillStateID","AND","Includes",0);
  
$WADbSearch1->addComparisonFromEdit("VisitorBillCountryID","S_VisitorBillCountryID","AND","Includes",0);
  
$WADbSearch1->addComparisonFromEdit("VisitorBillZip","S_VisitorBillZip","AND","Includes",0);
  
$WADbSearch1->addComparisonFromEdit("userLevel","S_userLevel","AND","=",1);

  
//save the query in a session variable
  
if (== 1) {
    
$_SESSION["WADbSearch1_visitors_Results"]=$WADbSearch1->whereClause;
  }
}
else     {
  
$WADbSearch1 = new FilterDef;
  
$WADbSearch1->initializeQueryBuilder("MYSQL","1");
  
//get the filter definition from a session variable
  
if (== 1)     {
    if (isset(
$_SESSION["WADbSearch1_visitors_Results"]) && $_SESSION["WADbSearch1_visitors_Results"] != "")     {
      
$WADbSearch1->whereClause $_SESSION["WADbSearch1_visitors_Results"];
    }
    else     {
      
$WADbSearch1->whereClause $WADbSearch1_DefaultWhere;
    }
  }
  else     {
    
$WADbSearch1->whereClause $WADbSearch1_DefaultWhere;
  }
}
$WADbSearch1->whereClause str_replace("\\''""''"$WADbSearch1->whereClause);
$WADbSearch1whereClause '';
?>



note the addition of the function WAQB_getEndDate to the end date clause.

Sign in to reply to this post

enquiry272230

Thanks Dave,
The pages were created using the Data Assist Wizard
From memory, the Search Wizard options you have displayed were not available at setup and are not available in Server Behaviours>DataAssist Search(WADAvisitors)

Obviously the Data Assist Search Wizard has more options, I have not used it yet.

I believe I would have had to create new pages with the Data Assist Search Wizard, if I read it correctly.
I chose to modify the pages already created, so as to retain the existing results functions, like - add/edit/delete, etc., so I searched for and found modification solutions within this forum.

Sign in to reply to this post

enquiry272230

I get from your code, that you might have assumed that the end date is the problem.
It's the start date (Oldest) that skips the first day.

e.g.
$WADbSearch1->addComparisonFromList("VisitorDate","S_VisitorDate","AND",">=",2);

Or same with "Edit":
$WADbSearch1->addComparisonFromEdit("VisitorDate","S_VisitorDate","AND",">=",2);

If I could just get a "minus one day (-1)" in there somewhere it might fix it, because otherwise it works perfectly.

Sign in to reply to this post

Dave BuchholzBeta Tester

To answer your first point having checked now it would seem that you cannot open the search wizard if your pages were created with the data assist wizard, I don't use the wizard as a general rule only the individual server behaviours.

On your second post I use this code all the time and it works just fine on date searches for me

Sign in to reply to this post

Jason ByrnesWebAssist

to get a beter idea of what is going on, add thr following code to you're page after the < <body> tag:

php:
SQL: <?php echo($query_limit_WADAvisitors); ?><br />




this will write out the sql query being used.

can you send a link to your search so we can test this?

Sign in to reply to this post

enquiry272230

Problem Solved.

It's weird, but since this post I uploaded the website to the clients domain host, and find that the search works perfectly.
I have previously been testing locally using Mamp Server on my Mac.
Locally on my Mac, the search omits the start date.
Remotely on the website, the search is perfect.

The remote server has PHP 5.2.9
MAMP on my Mac has PHP 5.2.6
I will have to check the local configuration and compare with remote, and perhaps download and install the latest version of MAMP

I thank you Dave and Jason for your efforts, and so sorry I have wasted your time.

Sign in to reply to this post

enquiry272230

The website is www.cinglebit.com, and is live.
Sorry I cant give you the Admin login in this post for security.
It's acedemic now anyway, thanks again.

Sign in to reply to this post

Dave BuchholzBeta Tester

Originally Said By: enquiry272230
  Problem Solved.
The remote server has PHP 5.2.9
MAMP on my Mac has PHP 5.2.6
I will have to check the local configuration and compare with remote, and perhaps download and install the latest version of MAMP  



That's interesting because I run MAMP Pro on my MAC and am currently running PHP 5.2.13 as that is the closest to my clients version and the date range has always worked perfectly for me. MAMP & MAMP Pro are currently at version 1.9.4 mamp-1-9-4-released.html

Sign in to reply to this post

Build websites with a little help from your friends

Your friends over here at WebAssist! These Dreamweaver extensions will assist you in building unlimited, custom websites.

Build websites from already-built web applications

These out-of-the-box solutions provide you proven, tested applications that can be up and running now.  Build a store, a gallery, or a web-based email solution.

Want your website pre-built and hosted?

Close Windowclose

Rate your experience or provide feedback on this page

Account or customer service questions?
Please user our contact form.

Need technical support?
Please visit support to ask a question

Content

rating

Layout

rating

Ease of use

rating

security code refresh image

We do not respond to comments submitted from this page directly, but we do read and analyze any feedback and will use it to help make your experience better in the future.

Close Windowclose

We were unable to retrieve the attached file

Close Windowclose

Attach and remove files

add attachmentAdd attachment
Close Windowclose

Enter the URL you would like to link to in your post

Close Windowclose

This is how you use right click RTF editing

Enable right click RTF editing option allows you to add html markup into your tutorial such as images, bulleted lists, files and more...

-- click to close --

Uploading file...