Tuesday, October 26, 2010

Calculated columns cannot contain volatile functions like Today and Me

When you trying to add calculated formula in list based on current date. You add '[Today]' in your formula and you give error like:- "Calculated columns cannot contain volatile functions like Today and Me". See image below:-

To solve this error use following steps:-

  1. Open up the List Settings page where you want this column.
  2. Create column named “Today”. The type doesn’t matter here, so let type as “Single Line of Text” and just click “Ok” 

3. Now create the calculated column where you need to use current date within formula and add “Today” from available columns.

4.Once this is done, we no longer need that our own generated column “Today” so you can delete it (Although when you need to edit formula you will need this again, so either recreate this dummy Today field or make it hidden using code behind. Otherwise SharePoint will put you again on that error screen).

5.For calculated fields, calculated value is stored in Database when item is created at first time and doesn’t change until item is edited. So using Today doesn’t means each time you will get value re-calculated as per actual today’s date. For that it is better to use Computed column.

1 comment:

  1. What use is the today column trick if Today only = Last Modified?