Hi all,
I have a table that stores the date in "DateOpened" field when work order is open and when it is closed via a check box, it auto populates the "DateClosed" (with now()) and the " TimeOpen" fields which works as it should. The problem I am running into is date will subtract hours,min,seconds but will not subtract the day. In other words if I opened a ticket yesterday at 12:00pm and closed it today at 2:00pm it shows only open for 2 hours not 1 day and 2 hours or 22 hours. Here is my jscript code used in the Onload event..
Thanks for your help in advance..
**
var d = new Date();
var ctrlCheck= Runner.getControl(pageid, 'Closed');
var ctrlDate = Runner.getControl(pageid, 'DateClosed');
var TO = Runner.getControl(pageid, 'TimeOpen');
ctrlCheck.on('change', function(e){
if (this.getValue() == 'on'){
ctrlDate.setValue(d);
}
var CD = Runner.getControl(pageid, 'DateOpened');
now = new Date();
var DO=new Date(CD.getValue());
var age=Math.floor(( Date.parse(now) - Date.parse(DO)+ (24 60 60 365 1000))); ;
milliseconds = age
mydate=new Date(milliseconds);
humandate=mydate.getUTCDay()+" day(s), "+mydate.getUTCHours()+" hours, "+mydate.getUTCMinutes()+" minutes and "+mydate.getUTCSeconds()+" second(s)";
TO.setValue(humandate);
});