Notifications

8 views

Description

There are different API's available to find the difference between 2 date fields on a record. Datediff in one of them along with subtract function used to find the difference between 2 date/time fields.

This KB talks about a scenario where the datediff function produce an exception by displaying the result with one day less than the expected output.

Instructions

Based on this scenario, the object is called this way in the transform script which is resulting in this issue

OutputDays = (gs.dateDiff(source.u_trip_start_date,source.u_trip_end_date,false)).split(' ')[0];

Try using the datediff function this way to have the result according to the actual difference between the 2 date fields. Here is a sample to find the difference between 2 dates.

var gdt1 = GlideDateTime('2021-02-25');
var gdt2 = GlideDateTime('2021-04-01');
var duration1 = gs.dateDiff(gdt1.getDisplayValue(), gdt2.getDisplayValue(), false);
gs.print("diff " + duration1);

Article Information

Last Updated:2020-07-14 10:17:27
Published:2020-07-14