0

I have made a few differents options for days pending with SharePoint. I would like to know, how many days a item is open.

First i tried this solution: https://www.solwebsolutions.com/blog/entry/calculate-age-of-sharepoint-list-items I tried this solution, i deleted the today columns. After this, "SharePoint automatically refers "Today" (which has been deleted now) as the today’s date in the formula calculation." but that don't work.

Second option: =DATEVALUE(TEXT(NOW(),"mm/dd/yyyy")) - DATEVALUE(TEXT([Created],"mm/dd/yyyy")) Days since list item was created

Both option dont update the item by them self. Do you know why it don't work? I tested both option on two differents tenants.

Hopefully we can fix this :)

0

The fields in the list view will only be updated when somebody modifies a listitem, so that approach will not work. One option could be to display the items somewhere using a search resultat web part, and in the item display template calculate and show the age of the item

0

here is a Javascript solution you may want to look into. It's annoying and inconvenient that SharePoint will not update list fields automatically, but rather whenever its been updated manually or with non-OOTB solutions... Let me know if this helps!

Automatically calculate Todays date in SharePoint List


A. Save the following code into a js file(AgeInDays.js).

(function () {
    var overrideCtx = {};
    overrideCtx.Templates = {};
    overrideCtx.Templates.Fields = {        
        "AgeInDays": { "View": ShowAgeInDays}
    };

SPClientTemplates.TemplateManager.RegisterTemplateOverrides(overrideCtx);
})();

function ShowAgeInDays(ctx) {
    var created= ctx.CurrentItem.Created;        
    return countDay(created);
}
function countDay(date){
    var b = new Date(date);
    var e = new Date();
    var dif = e.getTime() - b.getTime();
    var day = Math.floor(dif / (1000 * 60 * 60 * 24));
    return day; 
}

B. Upload the js file into the Site Assets library.

C. Edit the list view page and add the text below into the JS Link property in the web part editor.

`~site/SiteAssets/AgeInDays.js`
0

I used this method, flow.

https://sharepointlibrarian.com/2017/12/08/use-microsoft-flow-to-create-a-today-column-for-use-in-sharepoint-list-calculations/

The flow runs perfect. It was 5 mins work to solve this with flow. Hopefully someone will use this option too.

  • Doesn't it causes havoc in the version history ? – Kasper Bo Larsen Aug 3 '18 at 11:10

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.