martedì, luglio 24, 2007

SharePoint: Creating a view on a list to display items created "yesterday"

Here’s a handy tip I stumbled upon from this blog.

 

We can easily filter a list to show everything created today by using the [Today] variable, but I was just asked by a colleague if it is possible to filter on [Yesterday]. For example I have an Issues List and if today’s date is 25th April, I want to show issues that were created on 24th April.

 

As you may or may not be aware it is not possible to simply substitute [Today] for [Yesterday] or [Today]-1 so this is how I went about solving the little problem.

 

Firstly create your list and add a calculated field with the value of "=[Created]+1". This will automatically create you a field with tomorrows date in it, Sounds a bit wierd at the moment but hang in there!

 

Next we need to create a view on the list we need to filter, I simply created a new view called "Yesterdays Issues" and filtered it on the "Tomorrows Date" field where all entries equal [Today].

 

Now if you create a new item in your list and switch to the "Created Yesterday" view you should see there are no entries.

 

However if you wait until tomorrow, or wind your system clock on a day and click refresh you should see all the entries created 'Yesterday'