giovedì, giugno 14, 2007

SharePoint: using the [Today] variable in a calculated field

This great post explains a way to actually use the [Today] variable in a calculated field!

“[Why is it difficult to] filter by [Today] - 5 so I can show items added or modified in the last 5 days?” It turns out you can using the following workaround:

 

  1. Add a new field to the List or Document Library named Aging or whatever you prefer.
  2. Set the Type to Calculated.
  3. Set the Description to "(Filter - Last 5 days)" or whatever you prefer.
  4. Set the Formula to
        =DATE(YEAR(Modified),MONTH(Modified),DAY(Modified)+5)
  5. Set The data type returned from this formula is: to Date and Time
  6. Set the Date and Time Format: to Date Only. Don't add it to the default view (unless you want to)
  7. On the View in question, set the filter to
    Aging is greater than (or equal to) [Today]

 

The filtered view will now only show items that have been modified in the last 5 days. You can adjust the formula for the field (or add another) to get a different filter (last 10 days, last month, last year, etc).

*

Also, a few other great formula pages I ran across:

Examples of common formulas

Today and Calculations