0
I have a list at Sharepoint with the code below: I need to compare the date of the 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 03/03/2017 and the field "Data_x0020_de_x0020_delivery" is on 20/02/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'/>";
}
}
Voce comparing two strings, Voce should compare two objects
Date
– andrepaulo