How to add duration field type to date time field?

KARTIK17
Tera Contributor

How to add the duration field(days and hours) to the date time field dynamically and store the result in date time format?
eg.
sla time = 5 days 1 hour
due date = current time(2023-11-28 08:10:50)  + sla time

1 ACCEPTED SOLUTION

Samaksh Wani
Giga Sage
Giga Sage

Hello @KARTIK17 

 

You need to write a Script for this :-

 

var sla = current.sla_time;
var datetime =sla.split(" ");
var date = datetime[0];
var time = datetime[2];

var gdt = new GlideDateTime(gs.nowDateTime());
gdt.addDays(date);
gdt.addSeconds(3600*time);
current.due_date=gdt;

 

Plz mark my solution as Accept, If you find it helpful.

 

Regards,

Samaksh

View solution in original post

5 REPLIES 5

Hello @KARTIK17 

 

The reason behind is you wrote:-

 

gbt.seconds, It should be gbt.addSeconds(ts);

 

Plz mark my solution as Accept, If you find it helpful.

 

Regards,

Samaksh