I am trying to determine by date if an item is due. In my use case, my user will create an item with a date in the following format (MM/DD or 06/15). Now if the date the user chooses will fall in the next 30 days or month then it will turn red. If the date will fall within the next 60 days or less (until it reaches 30) then it will be orange and if greater than 60 they will be yellow.
so just to clarify, if my date <= 30 days from today's date then turn red and so on...
I was looking into Date.js to perform these calculations but unsure of how to get started.
What I was thinking so far was the following:
var _dueDate = new Date()
var now = Date();
var nowPlus30 = new Date();
nowPlus.setDate(now.getDate() + 30);
var nowPlus90 = new Date();
nowPlus.setDate(now.getDate() + 90);
if (_dueDate == '' || !_dueDate) {
return '';
}
and then just using the values to change the background color for example:
if( _dueDate <= nowPlus30 ) //find the data to use to determine the color
{
x[i].parentNode.style.backgroundColor = 'orange'; // set the color
}
but doing these for each condition has not worked so far so I think using Date.js may help but again, no idea how to proceed and because I can't use SharePoint designer to use those built in conditional statements I have to use javascript to do the operation.
please help!