Select formula in the view

Hello, My question is how to write a formula in the view select to filter the documents which contains a checkedDate is in last two month.

for example, @Now=Feb 21,2008, we want to have all document which the @month(checkDate) is between Dec 21,2008 to feb 21,2008.

we used a formula :& ((@Now) - DateConsulted) < 5184000

but the thing is if @Now=March 1,2008, the collect documents includes Dec, 2007 as there are 29 days in Feb 2008. We only wnat to have the documents in March, Feb and Jan, no Dec,2007.

So, we can not to use days (518400) (60days) as formula.

I appreciate any suggestions in advance.

thanks,

Linda

Subject: Select formula in the view.

@Now should not be used in view selection formulas due to the impact it has on performance due to view indexing.

There are several ways to do this such as using @Texttotime or running a daily agent that either sets a flag on the documents that should appear in the view or updates the view selection formula with a hard coded date.

Search the forum for something like View Selection @Now and you will find several discussions with the pros and cons of each method.

Subject: RE: Select formula in the view.

I know it’s true. But I have no idea how to use @Testtotime or runnung a daily agent. I will do some searching as you said.

Thank you very much for your tips.

Linda.

Subject: RE: Select formula in the view.

U can schedule the agent to run daily at a particular time… It can be done from agent properties (which opens wen u open an agent or by right clickin in an agent and selecting agent properties - Think u already know it, jus incase u dont.)

There at the bottom in Runtime select “On Schedule” and then click on schedule to select time and then select daily…

Think tht will solve part of ur problem…

Subject: RE: Select formula in the view.

I know how to set up agent. I don’t know how to write coding of the agent.

Thanks a lot.

Linda

Subject: RE: Select formula in the view.

Linda, your agent should flag the documents that need to be displayed in the view. This is an example of how you do it:

  1. create another hidden text field named say: “showInView” in your forms.

  2. The formula for your scheduled agent should be something like this:

@if( DateConsulted >= @Adjust(@Today;0;-2;0;0;0;0) & DateConsulted <= @Today ; @setfield(“showInView” ; “1”) ; @setfield(“showInView” ; “0”))

You should run this agent on all your desired documents, if the document matches your criteria it sets the “showInView” field value to “1” otherwise to “0”

  1. The selection formula for the view should be: SELECT showInView = “1”

Subject: Select formula in the view.

DateConsulted >= @Adjust(@Today;0;-2;0;0;0;0) & DateConsulted <= @Today

This should select any document with DateConsulted between today and two months ago. This allows you to use the month parameter of @Adjust.

In the example you cite, the formula @Adjust([03/01/2008];0;-2;0;0;0;0) will return [01/01/2008] - it will not include the December dates.

Subject: RE: Select formula in the view.

Thank you so much Martha. I believe it will work fine. :slight_smile:

Linda