title: How to convert TIMESTAMP to UTC milliseconds in ESQL
body: <p>Is there an ESQL function to convert TIMESTAMP to UTC milliseconds?</p>
  
  <p>This is what I did:</p>
  
  <pre><code>DECLARE eventTimeInteger INTEGER CAST ((eventTimeStamp - epochTimeStamp) SECOND as INTEGER);  
  </code></pre>
  
  <p>But I keep getting this error. So I suspect the "-" is an issue but I'm not sure how else to go about this.</p>
  
  <p>BIP2420E: (.Event_SeparateMessages.Main, 142.60) : Invalid or incompatible data types for '-' operator. </p>
  
  <p>Either the data types of the operands of the operator were not valid for the operator, or the datatypes were incompatible. </p>
  
  <p>Correct the syntax of your ESQL expression in node '.Event_SeparateMessages.Main', around line and column '142.60', then redeploy the message flow: Ensure that the data types of the operands are valid and compatible with each other.</p>
  
  <p>This below is what I've tried but it won't even deploy. </p>
  
  <pre><code>--Converting time in string to timestamp
  DECLARE source CHARACTER eventTime ;
  DECLARE eventTimeStamp CHARACTER;
  DECLARE pattern CHARACTER 'yyyy-MM-dd''T''HH:mm:ss.SSS''Z';
  SET eventTimeStamp = CAST(source AS TIMESTAMP FORMAT pattern);
  DECLARE epochTimeStamp TIMESTAMP '1970-01-01 00:00:00';
  
  --Casting time from timestamp to Integer                       
  DECLARE eventTimeInteger INTEGER CAST ((eventTimeStamp - epochTimeStamp) SECOND as INTEGER);  
  </code></pre>
  
  <p>I need to have "eventTimeInteger" give me the timestamp in seconds.</p>