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

GlideDateTime.subtract doesn't work

abrouf
Kilo Sage

I used the following commands on default value to calculate the number of days subtracting current date to due date but didn't work. Any comment or advise is greatly appreciated.

javascript:calendar_duration = GlideDateTime.subtract(due_date.getDisplayValue(), gs.nowDateTime());

Following this syntax:

<duration_field> = GlideDateTime.subtract(<start_field>.getDisplayValue(),gs.nowDateTime());

21 REPLIES 21

Hi Mohammed Rouf,



Please correct your script and try running something like   this



var sgd = new GlideDate();


sgd.setValue('2018-03-21');


var tdy = new GlideDate();


tdy.setValue('2017-12-12');


duration = GlideDate.subtract(tdy,sgd);


gs.info(duration.getDisplayValue());




Hope this helps.... PLEASE MARK my answer as HELPFUL OR CORRECT if it served your purpose.


Yes, it subtracts the hardcoded date successfully but I need to make it read the dates from fields & then subtract.