calculateDateDifference¶
Calculates the time difference between two dates and returns the difference in 4 different time units: seconds, minutes, hours, and days.
Parameters¶
Combine the parameters as a JSON structure as input.
Parameter  | 
Mandatory/Optional  | 
Data Type  | 
Description  | 
|---|---|---|---|
startDate  | 
Mandatory  | 
String  | 
The start date and time.  | 
endDate  | 
Mandatory  | 
String  | 
The end date and time.  | 
startDatePattern  | 
Mandatory  | 
String  | 
The format for   | 
endDatePattern  | 
Mandatory  | 
String  | 
The format for   | 
Return Values¶
The four values returned will combine and form a JSON structure. Each value represents the same date difference, but in a different time unit. Do not add these values together.
Value  | 
Data Type  | 
Description  | 
|---|---|---|
dateDifferenceSeconds  | 
String  | 
The difference between the start and end date/time, truncated to the nearest whole number in seconds.  | 
dateDifferenceMinutes  | 
String  | 
The difference between the start and end date/time, truncated to the nearest whole number in minutes.  | 
dateDiffferenceHours  | 
String  | 
The difference between the start and end date/time, truncated to the nearest whole number in hours.  | 
dateDifferenceDays  | 
String  | 
The difference between the start and end date/time, truncated to the nearest whole number in days.  | 
Samples¶
var difference = tools.DateUtil.calculateDateDifference({"startDate" : "2021-03-09", "endDate" : "2021-03-10", "startDatePattern" : "yyyy-MM-dd", "endDatePattern" : "yyyy-MM-dd"});
return tools.resultBuilder.build(true, JSON.stringify(difference));
Output
"{\"dateDifferenceSeconds\":86400,\"dateDifferenceMinutes\":1440,\"dateDifferenceDays\":1,\"dateDiffferenceHours\":24}"