Jump to content

This topic is 7094 days old. Please don't post here. Open a new topic instead.

Recommended Posts

  • Newbies
Posted

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.

  • 2 months later...
Posted

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.

Posted

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...

Posted

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();

Posted

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

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.