Wednesday, April 16, 2008

How to calculate age of list items in SharePoint

Here are the steps to calculate age of the list items in SharePoint,

1. Go to the list where you want to calculate age of the items e.g. Task List
2. Click Settings => List Settings and create a new column and name it e.g. "Today", There is no need to select any specific type for this column (Just type the name of the column and click "OK" at the bottom)
3. Create one more column and name it e.g. "Age in Days". Select "Calculated(calculation based on other columns)" type and provide formula using "Today" column which you created in step 2 e.g. I have entered
=[Today]-[Created]. Select "number" for the data type and 0(zero) in "Number of Decimal places". So basically it will calculate difference between today's date and date the item was created.
4. After 3rd step, remove "Today" column, which you have created in step 2. When you remove Today column, SharePoint automatically refers "Today" (which has been deleted now) as the today's date in the formula calculation.
5. Go back to Task List and it should display the number of days under the "Age in Days" column of each items in Task List.

6 comments:

Unknown said...
This comment has been removed by the author.
Jayden12com said...

That's hilarious. I tried putting the [Today] variable directly into the calculated field and got an error so searched the web for a solution and was getting really long formulas. I thought there had to be an easier way to do it. It's funny that Sharepoint is picky enough to give you an error for something it can handle and then that it can be tricked into doing it anyway like this. Thanks for the idea!

Doug said...

When I use this approach the [TODAY] is not being updated automateically every day. it only updates the age when the record is modified.

shreejesh said...
This comment has been removed by the author.
shreejesh said...

Excellent Idea !!! I am able to implement this

João Vicentini said...

FANTASTIC Idea