Again a calculated field question, How can I create a calculated field to find out, what is the age of the entry.

In the list I will have a created date field, from that I would like to create a number field calculating the no of days from created day to today. I tried with =Today-Created, not working!!

Any inputs ? Thanks !!


Unfortunately, calculated column approach will not work as expected :( Calculated fields are updated only if the column itself is being updated, or the item is updated. You can fiddle with setting date to future in Windows to prove it.

So I would recommend you to use XSL transformations for XsltListViewWebPart in conjunction with dateUtils.xsl from Marc D Anderson. I'm using this method for displaying "Birthday is soon" indicator in Contacts lists:

enter image description here

Works like a charm.

Tentative code example (this will display "age" of item in days):

      <xsl:variable name="DaysToday">
        <xsl:call-template name="countDaysInDateWithLeapYearDays">
          <xsl:with-param name="paramDate" select="substring-before(ddwrt:TodayIso(),'T')"/>

      <xsl:variable name="DaysCreated">
        <xsl:call-template name="countDaysInDateWithLeapYearDays">
          <xsl:with-param name="paramDate" select="ddwrt:FormatDateTime(string($thisNode/@Created),1033,'YYYY-MM-dd')"/>

      <div class="indicator">
        <xsl:value-of select="number($DaysToday)-number($DaysCreated)" />

You should place this code into PrintTableCellEcbAllowed xsl template. And don't forget to include date_templates.xsl :) To learn more about XsltListViewWebPart templates, read following MSDN article:

  • Thanks, omlin let me see how to get this worked in a list column, hopefully it will for each list item separately :)
    – Jithu
    Nov 2 '11 at 12:03
  • Of course it will. Nov 2 '11 at 13:16
  • Added XSLT code sample to the answer Nov 2 '11 at 13:24

You can use Today with some trick, but the problem is that it will use the Today value from the day it was last modified. You'll then need to have something to modify the item each day/week/year, like a workflow.


If its not used for any other logic, only for showing I would maybe used a javascript to calculate the difference, or use a CQWP with an itemstyle that does the calculations. Guess it depends what you'll be using the field for.

  • Hi Andez, Thanks for helping me again, I am just using this field only for our reference purpose, like we have a task generated and we need to know , how old that task is? And we have to display it in the list!!
    – Jithu
    Nov 2 '11 at 10:58
  • How can we use Javascript to calculate a column values, I really don't know that method!!
    – Jithu
    Nov 2 '11 at 11:11
  • Hi as you said, I just went through the link you provided, however the problem you stated is really a mess. However got a good link for updating the fields dynamically - here it is . Looks like its gonna be a long day for just getting some days calculated !! Thanks !!
    – Jithu
    Nov 2 '11 at 11:22

I have been successful with this formula: =DATEDIF([Created],[Today],"d") However, you have to create a Today column in the list leaving all the defaults. Then create this calculated column referencing that Today column. Then delete the Today column.

  • Thank you spevil, I think still I should create a separate TODAY column!!
    – Jithu
    Nov 2 '11 at 11:25
  • Getting Error!! =DATEDIF([Created],[Today],"d")
    – Jithu
    Nov 2 '11 at 11:29
  • I corrected the entry. I should have better explained it! Nov 2 '11 at 11:43
  • 1
    I'm afraid this will not work :( Based on my own experience. Also have a look to this post: blog.pentalogic.net/2008/11/… Nov 2 '11 at 11:56
  • 1
    My solution works for what I used it for. However, I like the XSL approach and Marc's stylesheet is very useful. Nov 2 '11 at 14:44

I wrote an article a while back about the different methods for creating a CountDown on a list view, which is essentially what you're looking for (well, a CountUp):

Warning: This also mentions our own product as a possible solution

How to create a Countdown in a SharePoint list

Here is a summary of the options:

  • JavaScript: Use a Content Editor Web Part.
  • Designer: Create a custom view in SharePoint Designer.
  • Code: Make your own custom field type from scratch.
  • SharePoint Highlighter: Buy our product.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.