CRM 2011 – Comparing only dates in Javascript

I was trying to compare some dates in Javascript today, I wanted to know if one dates was less than another, if it was I set the a status to overview.

When I compared the dates I found my CRM date had set the hours, minutes, seconds to 0,0,0 which is correctly because I wasn’t interested in storing the hours and minutes.

When I compared that date to todays date in Javascript it was coming up less because todays date had the current time in it.

so to compare the dates I used the setHours method to blank the time from the date then you can compare just the date values.


var reviewDate = Xrm.Page.getAttribute(“followupby”).getValue();
var currentTime = new Date();
currentTime.setHours(0, 0, 0, 0);
if (reviewDate < currentTime) {
//kpi incomplete
} else {