I have a list in sharepoint with the code below: I need to compare the date field "Data_x0020_de_x0020_Delivery" with the current date "today", but by the code below is comparing only the first digit of the date, for example, if today is 3/3/2017 and the "Data_x0020_de_x0020_Delivery" field is in 02/20/2017 is comparing only the first digits in the case, '03' with '20'
How do I compare the two dates?
(function () {
var fieldCtx = {};
fieldCtx.Templates = {};
fieldCtx.Templates.Fields = {
"Progress": {
"View": ProgressFieldViewTemplate
}
};
SPClientTemplates.TemplateManager.RegisterTemplateOverrides(fieldCtx);
})();
function ProgressFieldViewTemplate(ctx) {
var _statusValue = ctx.CurrentItem.Data_x0020_de_x0020_Entrega;
var today = new Date();
var dd = today.getDate();
var mm = today.getMonth()+1; //January is 0!
var yyyy = today.getFullYear();
if(dd<10) {
dd='0'+dd
}
if(mm<10) {
mm='0'+mm
}
today = dd+'/'+mm+'/'+yyyy;
if (_statusValue > today)
{
return "<img src='https://xxxxxxxxxxxx/sites/intralogo/SiteAssets/icons/Green.png'/>";
}
else if (_statusValue == today)
{
return "<img src='https://xxxxxxxxxx/sites/intralogo/SiteAssets/icons/Yellow.png'/>";
}
else if (_statusValue < today)
{
return "<img src='https://xxxxxxxxx/sites/intralogo/SiteAssets/icons/Red.png'/>";
}
}