Aras Innovator Platform

How to Handle Date Properties

You want to programmatically get/set date properties

Technique

Convert date values to “yyyy-MM-ddThh:mm:ss” format before setting the property

JavaScript

// Get yesterday’s date
var myDate = new Date();
myDate.setDate(myDate.getDate()-1);
// Find all methods edited in the past 24 hours
var myItem = this.newItem(“Method”,"get”);
myItem.setAttribute(“select”,"name”);
myItem.setProperty(“modified_on”,dateFormat(myDate));
myItem.setPropertyAttribute(“modified_on”,"condition”,"gt”);
myItem = myItem.apply();
// Loop through the returned methods and return the list
var methodList = new String("");
for (var i=0; i<myItem.getItemCount(); i++) {
methodList += myItem.getItemByIndex(i).getProperty(“name”,"") + ", ";
}
top.aras.AlertError(“The following methods were modified in the past 24 hours: "+methodList.substr(0,methodList.length-2));
function dateFormat(d) {
var dateString = d.getFullYear()+"-";
dateString += pad(d.getMonth()+1)+"-";
dateString += pad(d.getDate())+"T";
dateString += pad(d.getHours())+":";
dateString += pad(d.getMinutes())+":";
dateString += pad(d.getSeconds());
return dateString;
}
function pad(x) {
return (x<10) ? “0"+x : ""+x;
}