SharePoint Stack Exchange is a question and answer site for SharePoint enthusiasts. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

i need to show date in "Time Ago" format?? how can i achieve this ?? we use XSLT to display announcements and here is XSLT code for date:

enter image description here

share|improve this question
There is no out of the box function to do that. You'd have to roll your own XSL template to evaluate the given date against the current date. It gets messy fairly quickly, with months having different numbers of days, leap years, etc. I have a template that is fairly accurate and only shows "xx days ago" and works fine over the year break period. If you're interested, I can post that. If you need something more complex like "2 Years, 5 months and 7 days ago", that would be a different story. – teylyn Apr 21 '13 at 2:22
@Benny Skogberg: if possible post, i'll play with it to achieve my requirement – Sachchin Annam Apr 21 '13 at 17:26

Try this formula, should print somehting like e.g X days X hours XX min :

=YEAR(Today)-YEAR(Created)-IF(OR(MONTH(Today)<MONTH(Created),AND(MONTH(Today)=MONTH(Created),DAY(Today)<DAY(Created))),1,0)&” years, “&MONTH(Today)-MONTH(Created)+IF(AND(MONTH(Today)<=MONTH(Created),DAY(Today)<DAY(Created)),11,IF(AND(MONTH(Today)<MONTH(Created),DAY(Today)>=DAY(Created)),12,IF(AND(MONTH(Today)>MONTH(Created),DAY(Today)<DAY(Created)),-1)))&” months,“&Today-DATE(YEAR(Today),MONTH(Today)-IF(DAY(Today)<DAY(Created),1,0),DAY(Created))&” days”

This is to be used in the Calculated Column, which you could then show as part of the output columns without manipulating XSLT.

share|improve this answer

Marc Anderson has a very handy XSL template for date calculations. Not sure if it does exactly what you are looking for but you can find out more and download from here.

share|improve this answer

Your Answer


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.