Newbies alias29 Posted June 10, 2005 Newbies Posted June 10, 2005 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.
Garry Claridge Posted June 11, 2005 Posted June 11, 2005 Try this: $Search->AddDBParam('moddate',$startdate,'gte'); $Search->AddDBParam('moddate',$enddate,'lte'); Good Luck. Garry
mlindal Posted August 31, 2005 Posted August 31, 2005 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.
Garry Claridge Posted September 1, 2005 Posted September 1, 2005 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
mlindal Posted September 2, 2005 Posted September 2, 2005 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...
mlindal Posted September 6, 2005 Posted September 6, 2005 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();
Steve T. Posted September 6, 2005 Posted September 6, 2005 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
Recommended Posts
This topic is 7094 days old. Please don't post here. Open a new topic instead.
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now