How can I add duration field value to a date/time field value?

shradz
Kilo Explorer

Hi Guys,

How can I add a duration field value   to a date/time field?

Last working day= resigned date(date/time field)+ notice period days (duration field value). I am writing an on-change request and passing values to a script include to calculate last working day.

Note: Last working day should be autopopulated and it should be in the date format.

e.g if resigned date is 1/10/2016

        notice period days =30 days

        last working day should be 30/10/2016

find_real_file.png

Thanks

shraddha

10 REPLIES 10

Hi Prashant,



BR is running in Global application but not in the scoped application.


find_real_file.png


I can see that Geofrey's answer should be working provided you change the field name.


Hi Kalaiarasan,



Output is coming but it is not calculating the correct number of days.



find_real_file.png


You would have gotten the answer much earlier had you have given the complete information.



This should work. Make sure you change the field names.



var dc = new DurationCalculator();


  dc.setStartDateTime(current.u_date_time);


  dc.calcDuration((current.u_duration.getGlideObject().getNumericValue())/1000);


  gs.addInfoMessage(dc.getEndDateTime());