Getting wrong Duration days

DubeyN
Mega Expert

Hi,

I am trying to create a business rule to get the duration between two fields. I am using below script to get the duration:

*******************************************************************
stts = current.u_status;
if (stts =='Published')
{
var strt = current.u_tariff_effective_date;
var end = current.u_start_time;
var diff = calcDurationSchedule(strt,end);
gs.addInfoMessage(diff);
current.u_duration = diff;
}

function calcDurationSchedule(strt, end) {

var realStart = strt.getGlideObject();
var realEnd = end.getGlideObject();

gs.addInfoMessage(realStart);
gs.addInfoMessage(realEnd);

var schedRec = new GlideRecord('cmn_schedule');
schedRec.get('name', 'Weekdays 24 / 7');
var sched = new Packages.com.glide.schedules.Schedule(schedRec.sys_id);
dur = sched.duration(realStart,realEnd);
return dur;
}
*************************************************************************

Problem : When I make changes to the form, this Business rule get triggered. But I am getting wrong business duration. I have added 3 gs.addInfoMessage to get start date, end date and duration returned. I am getting correct date for Start date (2012-02-08) and End Date (2012-03-19) . But Duration returned is a date "1970-01-01 00:00:00". I am not sure why it returning date instead of number of days. Am I missing anything?

Thanks in advance.

ND

11 REPLIES 11

DubeyN
Mega Expert

Hi,

Thanks for update.

I just added the time zone in the schedule and it is working now. Not sure what the relation with the time zone when we are considering 24 hour a day.

ND


Not applicable

It shouldn't/won't be timezone related.

If you don't explicitly set a timezone it will use your current session's timezone.

There must be something else happening. Please open an incident with Support, so that it can be investigated in detail.