Monday, March 13, 2017

Calculate days difference between 2 dates sharepoint + JQuery

// This function calculates the difference between the Date field of SharePoint and the current Date.
function calculateDays()
{
var myDate =  $('input[title="Date"]').val();
var chunks = myDate.split('/');
var formattedDate = new Date([chunks[1],chunks[0],chunks[2]].join("/"));
var currDate = new Date(new Date().getTime());
console.log( Math.floor((currDate-formattedDate)/(1000*60*60*24)));
return Math.floor((currDate-formattedDate)/(1000*60*60*24));
}

No comments:

Post a Comment

Clearing Person/Group Values

To clear out or empty the values in person or group columns, how you do it depends on if the column is single-value or multi-value. For ...