Viewing Document within a Time Perdod

kevsh
kevsh used Ask the Experts™
on
In the VIEW section is there a way to view document that fall within a time period.  I want to create a View that will only show the documents created between the previous Sunday to the next Sunday
Comment
Watch Question

Do more with

Expert Office
EXPERT OFFICE® is a registered trademark of EXPERTS EXCHANGE®

Commented:
Here's a selection formula you can use:

Date := @Created;

DaysSinceLastSunday:=@WeekDay(@Today)-1;
PreviousSunday:=@Adjust( @Today; 0; 0; -7-DaysSinceLastSunday; 0; 0; 0);
LastSunday:=@Adjust( @Today; 0; 0; -DaysSinceLastSunday; 0; 0; 0);

SELECT Date => PreviousSunday & Date =< LastSunday;

Use => or > and =< or < after your needs.

NOTE - this is a time sensitive selection formula (uses @Today), which means it will be very server demanding since the view selection will never be constant.

There are a number of articles and tipses on how do time-sensitive views best (some formula tricks and view properties). But I could not find them on the net now - you could try a search.

An different approach, to prevent using a time sensitive view, would be to run an agent every sunday updating a folder showing the documents as you want. The formula above could be extended for this.

Best of luck
I agree with STITT's suggest of an agent that runs each sunday, however instead of using a view -- which means "touching" all the documents so they meet the selection criteria, create a FOLDER and put the documents in the folder via the agent.
I dont know if stitts method worked or not.

Here is a simple view selection formula that is tested and working to perfection.

--------------------------------
Num := 8 - @Weekday(@Today);
NextSunday := @Date(@Adjust(@Today ; 0 ; 0 ; Num ; 0 ; 0 ; 0 ));
LastSunday := @Date(@Adjust(NextSunday ; 0 ; 0 ; -7 ; 0 ; 0 ; 0));
CreatedDate := @Date(@Created);
Select CreatedDate >= LastSunday & CreatedDate <= NextSunday;
--------------------------------

The view wont be constant is true.  But sometimes we need to go with such nasty solutions to keep our customers happy. And i have a few of this kind and the customer is overwhelmed.  Afterall they pay me for my living right ?

;-)
Arun.

PMI ACP® Project Management

Prepare for the PMI Agile Certified Practitioner (PMI-ACP)® exam, which formally recognizes your knowledge of agile principles and your skill with agile techniques.

Commented:
Actually I can see now that I read your question wrong. My selection formula returns documents created between last sunday and the sunday before.

But still... use an agent, and a folder.
The agent must run on schedule in which case what will be the schedule ?

If its a folder, then as and when the documents are created it may not be available in the folder immediately unless another job is run to make them available in the folder.

Instead, a view selection would work better.

Alternatively for folder method,

Any document that is created today can be added to the folder using folderoptions reserved field.

A nightly agent can run once a day against this folder and remove the documents that are more than a week old...

What do experts think on this option ?
-Arun.

-

Arun,

An easy solution to the issue you suggest, is to schedule the agent to run periodically against unprocessed documents, and only once a week on all documents to do the changeover.

If an instant solution is required, a database script that runs "onSave" and puts the document where it should be when modified would work quite well.
I would prefer the instant solution. But lets hear from kevsh.

:-)

Author

Commented:
Yes, an instant solution would be ideal I think.  This particular view would only be called upon once a week.  The purpose is for a manager to call upon it to see all the new docs created from the previous week.  So Arun, I think your solution is best for me, just to be sure, will your formula show me all docs created in the past week between 11/10/02 and 11/17/02 (if i were to view it today).  Can you give me a line by line description so I can understand what it is doing exactly, I know very little about coding.
My code will take todays date and calculate the forth coming sundays date.

Then from there it will calculate the previous sunday.

Finally the date range documents are displayed using select statement.

In my case its from 17th to 24th.

A simple change will do to change it from 11th - 17th and the change would be done as follows.
Num := @Weekday(@Today);
NextSunday := @Date(@Adjust(@Today ; 0 ; 0 ; -Num ; 0 ; 0 ; 0 ));
LastSunday := @Date(@Adjust(NextSunday ; 0 ; 0 ; -7 ; 0 ; 0 ; 0));
CreatedDate := @Date(@Created);
Select CreatedDate >= LastSunday & CreatedDate <= NextSunday;

All i did in the above was to remove the 8- that would fetch the next sunday. Instead i made the second variable -Num so that it gets the previos sunday and one week before will be fetched automatically by the third variable.

Tested code and working perfectly as you wanted.

-Arun.

Author

Commented:
Doh, actually I want the formula to be showing froma past Monday to Sunday formula, so if I were to view it today, I should see all docs created betwwen 11/11/02 to 11/17/02, sorry
Cut and paste this formula in view selection formula.
Design the first column to have the @Date(@Created) with
ascending and categorized.  This will show you only the categories by date created.  And you will see only docs for those period.

Well, i just noticed if the points were increased recently ?  

Hi Drew! I got this one i guess if I had missed the other one.

;-)

Author

Commented:
OK, does this formula need to be modified tho so it shows Monday to Sunday past week?
Nope !  Just cut and paste.  

If there might be documents created on sunday and you want to exclude them, just change the last line as follows,

Select CreatedDate > LastSunday & CreatedDate <= NextSunday;

Note that i have removed the = from the first criteria of checking.

Good Luck!
Arun.
PS: Can this go only upto 150 ?  Why not 500 ?  *jus kidding*

Author

Commented:
OK, does this formula need to be modified tho so it shows Monday to Sunday past week?
Do you want the description to read Monday to Sunday Past week in the view ?

All you have to do is in the first column put this formula,
"Monday to Sunday Past Week" and categorize it with a twistie so that you can have all the documents under this category.

-Arun.

Author

Commented:
OK, does this formula need to be modified tho so it shows Monday to Sunday past week?

Author

Commented:
huh?
I am confused now completely.

:-&

Author

Commented:
huh?
uh Oh.... what is this ?

Author

Commented:
Ok Arun, lets start from the beginning, I create a new view.  Copy your formula into the formula window of the view selection.  I also create a new column with the @DATE(@CREATE) field so that it can actually see the dates and sort them out.  Im not sure about what you meant by Description, your last comment.

Author

Commented:
Ok Arun, lets start from the beginning, I create a new view.  Copy your formula into the formula window of the view selection.  I also create a new column with the @DATE(@CREATE) field so that it can actually see the dates and sort them out.  Im not sure about what you meant by Description, your last comment.

Author

Commented:
Ok Arun, lets start from the beginning, I create a new view.  Copy your formula into the formula window of the view selection.  I also create a new column with the @DATE(@CREATE) field so that it can actually see the dates and sort them out.  Im not sure about what you meant by Description, your last comment.
Ok lets start from beginning.  The first column formula that you are trying is wrong.

It should read as @Date(@Created).  Make this as ascending categorized with twisties enabled.

When you save this and come out, you will have dates from last monday to past sunday only.

-Arun.
Zvonko זְאֵבSystems architect
Top Expert 2006

Commented:
No comment has been added to this question in more than 21 days, so it is now classified as abandoned.

I will leave the following recommendation for this question in the Cleanup topic area:
    Accept: Arunkumar {http:#7473544}

Any objections should be posted here in the next 4 days. After that time, the question will be closed.

Zvonko
EE Cleanup Volunteer

Do more with

Expert Office
Submit tech questions to Ask the Experts™ at any time to receive solutions, advice, and new ideas from leading industry professionals.

Start 7-Day Free Trial