I have found plenty of examples on using a calculated column to display days since created. That was a simple excel formula in a calculated column. I need to display days since modified that updates on a page onload. Calculated column values only update when the field is modified so it will always calculate 0.

My SharePoint OOTB is great, but not so strong on creating my own scripting. Any assistance would be great.

  • Which version of SharePoint? And if SharePoint Online, is this for classic or modern UI? – Mike Smith - MCT - MVP Sep 21 '18 at 18:04

Use below for SP 2013/SharePoint Online Classic view. Modern view doesn't support Jquery

$(document).ready(function () {
    var today = new Date();
    var dd = today.getDate();
    var mm = today.getMonth(); 
    var yyyy = today.getFullYear(); 
    if(dd<10) {
    if(mm<10) {
    var todaysDate = new Date(yyyy,mm,dd);

    var date = $("#fieldName").text();

    var dateParts = date.split('/')
    var year = dateParts[2]; 
    var day = dateParts[1];
    var month = dateParts[0]-1;//January is 0!
    var reviewDate = new Date(year,month,day);      

    oneDay = 24*60*60*1000;
    var diffDays = Math.round(Math.abs((todaysDate.getTime() - reviewDate.getTime())/(oneDay)));

| improve this answer | |

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.