Calculate Time Difference between DateTime fields

Hi,

We are trying to calculate time difference, between 2 Date fields that are in format - 2020-08-23T11:43:54.000Z (this is show on Graylog as 2020-08-23 11:43:54 +00:00)
Looking on how to do that, we found the Code below which is supposed to give us the result we need.

However, we are getting errors like this:
For rule ‘calc_processing_time’: In call to function ‘parse_date’ at 10:34 an exception was thrown: Invalid format: “2020-08-23T19:43:54.000+08:00” is malformed at “20-08-23T19:43:54.000+08:00”

Code:
rule “calc_processing_time”
when
// REQUESTTIME Format hh:mi:ss.mmm
has_field(“REQUESTTIME”) AND
// RESPONSETIME Format hh:mi:ss.mmm
has_field(“RESPONSETIME”)
then
// the math of RESPONSETIME minus REQUESTTIME
// translated to milliseconds
set_field( “processing_time”, parse_date(
value: to_string($message.REQUESTTIME),
pattern: “HH:mm:ss.SSS”,
locale:“en” ).millis - parse_date(
value: to_string($message.RESPONSETIME),
pattern: “HH:mm:ss.SSS”,
locale:“en” ).millis );
end

Can any1 assist with this?

Thanks,
Jacob

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.