This topic is locked
[SOLVED]

 Filtering Record Dates

2/8/2012 10:02:34 AM
PHPRunner General questions
A
ant author

Can someone please assist, I am trying to filter my records by Invoice Date. I want to find records that were invoiced in a particular month or between 2 date periods.
Thanks

C
cgphp 2/8/2012

The "Before SQL query" event is executed before the SELECT SQL query is processed. Use that event if you like to modify the WHERE clause of your query:

$strWhereClause = whereAdd($strWhereClause, "MONTH(date_field_name) = '".$month_value."'");
A
ant author 2/9/2012



The "Before SQL query" event is executed before the SELECT SQL query is processed. Use that event if you like to modify the WHERE clause of your query:

$strWhereClause = whereAdd($strWhereClause, "MONTH(date_field_name) = '".$month_value."'");



Hi Cristian
Thanks for the help, im learning as I go along;
I'm getting a error and I think i need to have a input for ".$month_value."
I place the following code in List page:Before SQL query;


/ Place event code here.

$strWhereClause = whereAdd($strWhereClause, "MONTH(Invoice_Date) = '".$month_value."'");

I get the following errors;

*php error happened

Technical information

Error type 8

Error description Undefined variable: month_value

URL 127.0.0.1/TimeoutBookings/output/Deals_Completed_list.php?

Error file C:\USB-Server\root\TimeoutBookings\output\include\Deals_Completed_events.php

Error line 103

SQL query
Call stack

File: line Function Arguments

0. include\Deals_Completed_events.php:103 runner_error_handler 1. 8;

  1. Undefined variable: month_value;
  2. C:\USB-Server\root\TimeoutBookings\output\include\Deals_Completed_events.php;
  3. 103;
  4. Array ( [strSQL] => SELECT leads.ID, leads.Customer_ID, leads.LeadDate, leads.Lead AS Consultant follow up, leads.Note, leads.Deal Done, leads.Priority AS Admin follow up, leads.Possi...;

    1. include\Deals_Completed_events.php:103 eventclass_Deals_Completed->BeforeQueryList 1. SELECT leads.ID, leads.Customer_ID, leads.LeadDate, leads.Lead AS Consultant follow up, leads.Note, leads.Deal Done, leads.Priority AS Admin follow up, leads.Possible AS Deal pending, ...;


  5. ;
  6. ORDER BY 9 DESC, 1 ASC;

    2. classes\listpage.php:1288 ListPage->buildSQL N/A

    3. classes\listpage.php:2233 ListPage->prepareForBuildPage N/A

    4. Deals_Completed_list.php:211 Global scope N/A*



    Where have I gone wrong and if what code would I use if I want to look up between 2 date inputs



A
ant author 2/12/2012

I managed to sort this problem out using the advanced search option. I did not know that the advanced search option gives you the ability to search between 2 dates.