Take the 2-minute tour ×
SharePoint Stack Exchange is a question and answer site for SharePoint enthusiasts. It's 100% free, no registration required.

I am creating a list whereby I want following function:

Current Day or Today - 2 days = Output Date

i.e.

23/12/2010 - 2 days = 21/12/2010

Is it possible to change the current dates dynamically also?

i.e. everyday the Current Day column automatically changes to the current date.

so on 24th December output will be

24/12/2010 - 2 days = 22/12/2010

How to do it?

Thanks! saumil

share|improve this question
    
Thx Friends! Does anyone a javascript solution to this issue? –  saumilm Dec 24 '10 at 16:10
1  
It would help if you describe what you are trying to do - then there may be alternatives. –  Ryan Dec 24 '10 at 17:01
    
I need a column which refreshes automatically to the current date. i.e. a Column shows date today, tomorrow date changes to tomorrow's date and so on without editing it. –  saumilm Dec 25 '10 at 7:53
add comment

4 Answers 4

up vote 4 down vote accepted

My colleague has written up the different ways to get this sort of countdown/count up display to work in SharePoint, including

  • JavaScript & CEWP
  • SharePoint Designer and DVWP
  • Visual Studio and custom code
  • 3rd party (disclaimer, one of the options is from my own company)

http://blog.pentalogic.net/2011/05/how-to-create-a-countdown-in-a-sharepoint-list/

share|improve this answer
add comment

You can't use "volatile" functions like [Today] in calculated fields. The reason is that the values of calculated fields are only computed when the list item is created or updated, so unfortunately it is not possible to do what you require using a calculated field.

You can "trick" SharePoint into allowing a [Today] expression in a calculated field by temporarily creating a column called "Today", then modifying the expression, then removing the temporary column. This circumvents the syntax checker but doesn't remove the underlying problem, because the value won't get updated until the next time you modify that list item.

It should be possible to do this with custom XSLT in an XmlListViewWebPart, or its predecessor DataViewWebPart (as mentioned in another answer). You could also do this with custom code, of course.

share|improve this answer
    
I've written a post about the [Today] trick that as you say doesn't work but seems to get bloged twice a month - blog.pentalogic.net/2008/11/… –  Ryan Dec 24 '10 at 17:03
    
Seriously, how does this stuff still get marked as answers? saumil, Please, I beg you to do your homework with the calculated [Today] trick. It simply is snake oil. Works once, but it'll never update, unless you update the item. It doesn't work! –  iOnline247 Dec 25 '10 at 2:25
    
iOnline247, that's exactly what I explained in my answer. –  SPDoctor Dec 26 '10 at 10:23
    
I apologize. I must've read it too fast. Sorry for the confusion SPDoctor. I'm bumping your answer now b/c I've made such a goof. –  iOnline247 Dec 27 '10 at 14:01
    
Okay, no problem. –  SPDoctor Dec 27 '10 at 19:35
show 1 more comment

There are kludgy workarounds for using [Today] in a calculated column, but they're really unnecessary, because [Today] in the context of a calculated column is the date the item is created.

Most likely, you'll want to use [Created]. If so, the calculation formula is pretty easy:

[Created]+2

HTH

Blessings, Jim Bob

share|improve this answer
    
Slight clarification: [Today] is equivalent to [Created] in the calculated default value for a date/time field. In a calculated field (assuming you used the kludgy workarounds!), it is initially the same as [Created], but is updated whenever you edit the list item. –  SPDoctor Dec 24 '10 at 10:23
add comment

Depending on your needs, you can do dynamic Date/Time math within a DVWP. You'll have to get comfortable with the date templates though. You can find a great post on this here: blogs.msdn.com/b/sharepointdesigner/archive/2008/02/25/filtering-and-formatting-with-date-values.aspx

If you have some q's about this, feel free to post back.

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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