compareDates¶
Compares two dates and returns the result as an integer.
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 the |
endDatePattern |
Mandatory |
String |
The format for the |
Note
If startDate
is 2021-03-10 (startDatePattern
is yyyy-MM-dd) and endDate
is 2021-03-10 11:11:55:111 (endDatePattern
is yyyy-MM-dd HH:mm:ss:SSS), this function will assume that the start date is earlier than the end date and return a -1 value. For more information on the return values, see Return Values.
Return Values¶
Value |
Data Type |
Description |
---|---|---|
Value |
Number |
|
Samples¶
var difference = tools.DateUtil.compareDates({"startDate" : "2021-03-10", "endDate" : "2021-03-10 11:11:55:111", "startDatePattern" : "yyyy-MM-dd", "endDatePattern" : "yyyy-MM-dd HH:mm:ss:SSS"});
return tools.resultBuilder.build(true, JSON.stringify(difference))
Output
-1