June 10, 200520 yr Newbies Having trouble figuring out how to search by date range. Here is what is have so far. On my find page I enter my two dates for the range to search by. <input type='text' name='startdate' value=''> <input type='text' name='enddate' value=''> On my Results page I pull my request values. $startdate=$_REQUEST['startdate']; $enddate=$_REQUEST['enddate']; Then I add the Param... $Search->AddDBParam('moddate',$startdate...$enddate); I have tried this different ways with what I have seen posted but no luck. Any help would be appreciated.
June 11, 200520 yr Try this: $Search->AddDBParam('moddate',$startdate,'gte'); $Search->AddDBParam('moddate',$enddate,'lte'); Good Luck. Garry
August 31, 200520 yr How can I modify this to search for transactions within the last 30 days? The concept is: $newdate = getdate() - 30; $search->AddDBParam(dateadded, $newdate); $search->AddDBParam(-op, 'gt'); In english: show all transactions where 'dateadded' > $newdate.
September 1, 200520 yr See if this displays what you want (then search on it): $newdate = time() - (30 * 24 * 60 * 60); echo date('d/m/Y',$today); Good Luck. Garry
September 2, 200520 yr not bad Gary, it shows the date to search from. I fixed the one error in your post where it should be $newdate rather than $today. Now to get the search to work. Using: $search->AddDBParam('-op','gt'); $search->AddDBParam('BookStore_DateAdded_Find',$newdate); produced a random found set that would show one publication and each refresh, a new single publication would come up...
September 6, 200520 yr Gary, Got it figured out and of course needed to translate the date from Australian (which you are) to Canadian to make it work. (ie in Canada it is date('m/d/Y', $newdate); so the correct search for all new transaction in the past 20 days is: $newdate = time() - (20 * 24 * 60 * 60); $newdate2 = date('m/d/Y', $newdate); $search->AddDBParam('DateAdded', $newdate2 , 'gte'); $searchResult=$search->FMFind();
September 6, 200520 yr Just FYI... I also did something like this with calculations in FM using status(CurrentDate) but it was only based on today. I forget the syntax, but it was something like thisday = status(CurrentDate) nextweek = thisday + 7 nextmonth = thisday +30 --ST
Create an account or sign in to comment