3

I have a list with columns naming may 17,June 17 to Dec 20.I want to restrict the columns of months based on current date.For ex: Today is 24/Aug/2017.

So when the page loads the fields of months starting from Aug 17 to Aug 18 should be displayed(12 months from current month)and other months should be hidden.

0

2 Answers 2

3

This can be done with just the UI, but you will need an actual Date column behind your Month/Year column. This will allow you to use date calculations in your view filter.

The easiest way to do this is to add a Date column. We'll pretend this column is called MyDate. Then you can create another column called Month that is a calculated column (of type single line of text) using the following formula:

=TEXT([MyDate],"MMM yy")

This will show the abbreviated names of the months (Like Dec in your question), but you could just add another M to the string format to get the full name (December).

Now, create another calculated column called MyDateInYear (of type Date) and set it to this formula:

=DATE(YEAR([MyDate])+1,MONTH([MyDate])+1,1)

Now you can setup a View using the UI and add 2 filter conditions:

  • MyDate <= [Today]
  • MyDateInYear > [Today]
2

The easiest way would be to have two separate views (web parts, div elements, sharepoint list view, etc) on a single page. Hide or unhide one based on the date being within the appropriate range using jQuery. Allows you to not have to worry about the sizing being all over the place as well.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.