Hi Stephen,
When you do date arithmetic and comparisons in JavaScript, it’s dealing in milliseconds. To get thirty days from now, this code will do it:
var currentDate = new Date();
var currentTime = currentDate.getTime();
//86400000 milliseconds in a day
var timeThirtyDaysHence = currentTime + (30 * 86400000);
var thirtyDaysHence = new Date(timeThirtyDaysHence);
console.log(thirtyDaysHence);
if (thirtyDaysHence > outstandingDate) {
$w('#statusButton').label = "Overdue"
$w('#statusButton').style.backgroundColor = "red"
}
You need to make sure the outstandingDate variable is a true Javascript date. There would be no need to use the toDateString() function. If I’m understanding the intent of your logic correctly, the test would be thirty days from now is greater than the outstandingDate.