how to add duration field to today date and time

rakhi1234
Kilo Contributor

i have duration field i am geeting 5days 2hr 50min 20 sec i want to add this duration to gs.nowdateandtime()./finall i want todaydate +5days 2hr 50min 20 sec,

5 REPLIES 5

anurag92
Kilo Sage

You can use


addSecondsLocalTime


and


addDaysLocalTime   function. Follow the below link and let me know if this helps


http://wiki.servicenow.com/index.php?title=Modify_a_GlideDateTime_Field_Value#gsc.tab=0


i am saying 5days 2hr 50min 20 sec all this add at a tiime if you query the duartion type field you can get like this


anurag92
Kilo Sage

Ok, so suppose you are trying to add Business Duration (of type duration) to now date time:



var gr = new GlideRecord('incident')


gr.addQuery('number','INC0000027');


gr.query();


if(gr.next())


{


var x=new GlideDateTime();


var y = (gr.business_duration.getGlideObject().getNumericValue())/1000;


x.addSeconds(y);


}



x is nowDateTime and y is the result i.e. addition of x and business duration.



Let me know if this helps.


Hi Anurag,


i am working on catalog item here delivery time(duration type) field is   available see below i am getting 5days 12 hrs 30 min 45 sec,here i ant to to add this entire duration to todatdate and time finally i want to get suppose (today +delivery time) =21/02/2017 12:30:45 like that


find_real_file.png