Calculating a time interval

This ESQL example calculates the time interval between an input WebSphere MQ message being put on the input queue, and the time that it is processed in the current Compute node.

(When you make a call to a CURRENT_ datetime function, the value that is returned is identical to the value returned to another call in the same node. This ensures that you can use the function consistently within a single node.)

 CALL CopyMessageHeaders();
 Declare PutTime INTERVAL;

 SET PutTime = (CURRENT_GMTTIME - InputRoot.MQMD.PutTime) MINUTE TO SECOND;
 
 SET OutputRoot.XML.Test.PutTime = PutTime;

The output message has the format (although actual values vary):

<Test>
 <PutTime>INTERVAL &apos;1:21.862&apos; MINUTE TO SECOND</PutTime>
</Test>
Related concepts
Message flows overview
Mappings
Related tasks
Developing message flows
Developing ESQL
Using numeric operators with datetime values
Related reference
Built-in nodes
ESQL reference
ESQL INTERVAL data type
ESQL numeric operators
Rules for ESQL operator precedence
CAST function