The CreatorCon Call for Content is officially open! Get started here.

How to add data of two time types

ma kaiyue
Giga Guru

I know the start time and the duration(they are all Time types),How to add them together or How can I get the end time?

find_real_file.png

1 ACCEPTED SOLUTION

suvro
Mega Sage

 

Set the fields as per your field name

var start_date = new GlideDateTime(current.u_start_date.getDisplayValue());

var end_date = current.u_duration.dateNumericValue();

start_date.add(end_date);

current.u_end_date = start_date.getValue();

View solution in original post

3 REPLIES 3

Sulabh Garg
Mega Sage

Hello

Try below code, use dateNumericValue() function which will convert duration back to seconds and will set it back to duration after adding another duration.

 

var dur = new DurationCalculator();

dur =gr.duration.dateNumericValue() + gr.duration.dateNumericValue();

gr.duration.setDateNumericValue(dur);

 

Please Mark Correct/helpful, if applicable, Thanks!! 

Regards

Sulabh Garg

Please Mark Correct/helpful, if applicable, Thanks!!
Regards
Sulabh Garg

suvro
Mega Sage

 

Set the fields as per your field name

var start_date = new GlideDateTime(current.u_start_date.getDisplayValue());

var end_date = current.u_duration.dateNumericValue();

start_date.add(end_date);

current.u_end_date = start_date.getValue();

Bhavana Reddy
Mega Guru

Do you want to add 2 fields ( one is date/time and another is of Duration type) ?

 

I tried adding 2 fields of type Time and cannot get the desired output