subtract(GlideDateTime start,GlideDateTime end) method provides wrong result when second argument passed is nullSummaryThere are various methods to calculate duration between two times. In this article, we would be focusing only on subtract(GlideDateTime start,GlideDateTime end) method. Below is the usage of the subtract(GlideDateTime start,GlideDateTime end) method. var pastDate = new GlideDateTime("2020-04-16 20:00:00");var currDate = new GlideDateTime("2020-04-17 20:30:55");gs.info("pastDate: " + pastDate); ------------ pastDate: 2020-04-16 20:00:00gs.info("currDate: " + currDate); ------------ currDate: 2020-04-17 20:30:55var dur = new GlideDuration();var dur = GlideDateTime.subtract(pastDate,currDate); gs.print(dur.getDisplayValue()); ------------- 1 Day 30 Minutes From the above script its clear that for the duration calculation we consider the difference of the days and minutes values and ignore the seconds. The date is passed to the GlideDateTime constructor to create pastDate and currDate which is why the results are correct. If no values is passed to the GlideDateTime constructor to create pastDate and currDate, the correct result with value "0" is returned. If no value is passed to GlideDateTime constructor to create currDate, then the resultant currDate will be in the UTC timezone so the subtract method that returns value will not be correct for the users in a different timezone. Hence in order to get accurate duration, gs.nowDateTime() needs to be passed as an argument to the GlideDateTime constructor to create currDate so that subtract will produce correct results. If the currDate value is fetched from a field, then a condition should be added to check if the field is empty or not to avoid the above issue. If the field doesn't have a value then handle the null values using if-else. Here is a sample on how to handle the null. This code should be copied before the use of subtract() method: if(currDate ==""){currDate = new GlideDateTime(gs.nowDateTime()); } Related LinksHere are a few references on the Developer site: For more details on the nowDateTime method click hereFor other usages of the subtract method click here