Its very easy using the filter feature of SharePoint views to show only items completed in the last 30 days or items due in the next X days; for example :-
Completed> = [Today]-30
On the advanced SharePoint view and filter techniques post Ed asked how you cocould filter for the current calendar month rather than a rolling 30 day period (for example all tasks due this calendar month ).
Like all great questions it seemed simple enough-something like only showing items where the month and year of the due date = the month and year of the current date.
Alas, we can't use [Today] In calculated columns and we can't use functions like month ([due date]) in the filter-so this approach will not work.
The solution is to turn this on its head-its a bit weird, so bear with me!
We need to have two calculated fields, one showing the first day of the month that the due date is in and one showing the last day of the month that the due date is in.
We can then use the filter to show only records where
[Today]> = first day of month
And
[Today] <= last day of month
So looking at this in graphical form we have:
Timeline
- In this distrithe current date is 15th Nov (the orange dotted line ).
- Task 1 & 2 shocould be shown if the current date [Today] is in between the first and the last day of November (the Blue Line)
- Task 3 will not be shown until [Today] is between the first and the last day of December (the Blue Line)
|
To put this into SharePoint open your list, click Settings> List Settings> Create column and setup the following two columns.
- The first column will be called something like start of month
- Set the column type to calculated and the data type to date only
- Uncheck the 'Add to default view' button as we want these columns to stay behind the scenes
- The start of month column formula shocould be
= Date (year ([due date]), month ([due date]), 1)
- The end of month formula :-
= Date (year ([due date]), month ([due date]) + 1, 1)-1 (Which is the first day of next month-1) |
View a few records to check the formula is working OK and you see the correct dates.
|
now create a new view, call it something like "due this month" and setup the filter for Start of month is less than or equal to [Today] and end of month is greater than or equal to [Today] |
Further tips
You can use this with date fields other than [due date]-e.g. [created] for items created in the current month, [modified] for items well... URM... Modified in the current month!
Using the same technique you can also use the following formula
The current week (Sunday to Saturday)
Start week = [due date]-weekday ([due date]) + 1
End week = [due date] + 7-weekday ([due date])
The previous month
Start month = date (year ([due date]), month ([due date]) + 1, 1)
End month = date (year ([due date]), month ([due date]) + 2, 1)-1
The next month
Start month = date (year ([due date]), month ([due date])-1, 1)
End month = date (year ([due date]), month ([due date]), 1)-1
The current year
Start Year = date (year ([due date]), 1, 1)
End year = date (year ([due date]), 12, 31)
Edit
I shoshould make clear that this technique will not work correctly on event lists with recurring event as SharePoint only records the start time of the first event, not each occurrence in the series.
References
Come from:
Http://blog.pentalogic.net/2009/11/howto-filter-items-current-calendar-month-view-sharepoint/