mcm-mgm
Posts: 1
|
| Posted: 04/12/2005, 7:41 PM |
|
Hi,
We have a grid which is to display table results, and we would like to have a search box above in which the user can select:
today
yesterday
last 7 days
this month
last month
year to date
and would like to have the grid display results for the given period.
How do we go about accomplishing this?
We noticed "procedure" as one of the list source options for a list box however we are unclear on its use.
Thanks.
_________________
mcm-mgm |
 |
 |
Nicole
Posts: 586
|
| Posted: 04/13/2005, 4:42 AM |
|
Hello,
You can try to implement date calculation in SQL query using date/time functions specific for your database. Build grid and Search form using builders. But I suppose that you need to fill dates listbox with custom list of values and build relevant WHERE part on a fly in Before Build Select event.
Even if you use the same datetime function to calculate date based on parameter passed from a search form you probably need different settings for it. In fact it is just an idea.
_________________
Regards,
Nicole |
 |
 |
Martin K.
|
| Posted: 04/14/2005, 9:56 AM |
|
|
|
|
 |
Martin K.
|
| Posted: 04/14/2005, 10:21 AM |
|
Quote Martin K.:
Hello.
You can try this:
In BeforeShow from your Listbox: (My Name in the Code for the Listbox = s_daylookfor)
$YourFormName->ListBoxName->Values = array(
array(mktime(0, 0, 0, date("m") , date("d"), date("Y")), "today"),
array(mktime(0, 0, 0, date("m") , date("d")-1, date("Y")), "yesterday"),
array(mktime(0, 0, 0, date("m") , date("d")-7, date("Y")), "last 7 days"),
array(mktime(0, 0, 0, date("m") , 1, date("Y")), "this month"),
array(mktime(0, 0, 0, date("m")-1 , 1, date("Y")), "last month"),
array(mktime(0, 0, 0, 1 , 1, date("Y")), "year to date")
);
In the Common.php:
#################################################
// The Function to Format a time() to MySQL Date
function CCGetReplyDate($ReplyDate) {
// today
$NewReplyDate = date("Y-m-d", time());
// if the Listbox has change and/or search
if($ReplyDate > 1)
// Set the date for the search StartDate
$NewReplyDate = date("Y-m-d", $ReplyDate);
// Return an MYSQl Date Format Date
return $NewReplyDate;
}
#################################################
And in the Grid, where you will List the searchresult:
Change to the Where Statement and Set your DateTime Field from the db (Type "Text" no DateTime !) , where we will searching about the Listboxfunction:
YourDateTimeField >= CCGetReplyDate(CCGetFromGet("s_daylookfor",""))
Type: Text Type: Application
Now you can search for your Wish in the Listbox.
If you do not understand how to integratet a Function in a CCS SQL, you can take a look in this message from me. It is always the same. http://forums.codecharge.com/posts.php?post_id=57524
sorry about my english,
greets martin
|
|
|
 |
|