Learning: how to use filters in Sharepoint to show items in the current calendar month

Source: Internet
Author: User

 

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

    • Date and Time Functions

Come from:

Http://blog.pentalogic.net/2009/11/howto-filter-items-current-calendar-month-view-sharepoint/

 

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.