title: Timestamp Comparison within Function
body: <p>To prevent older version overwrite new version, in this simple function:</p>
  <pre><code>create function myupdate(paramts timestamp without time zone, ...)
    language plpgsql AS
  $$
  begin
  -- step 1 compare current record timestamp vs. supplied timestamp
  if exists (select 1 from record where ts &lt;&gt; paramts and ...) then
      raise exception 'A newer version exists, cannot update.';
  end if;
  ...
  end
  $$;
  </code></pre>
  <p><code>ts</code> definition is the same <code>timestamp without time zone</code>.</p>
  <p><code>paramts</code> value is supplied by a function:</p>
  <pre><code>create function myfetch(...)
    language plpgsql AS
  $$
  begin
      return query select ts, ... from record where ...;
  end
  $$;
  </code></pre>
  <p>What node API and Angular client UI gets is <strong>2021-04-16T21:37:35.878Z</strong> so is the value submitted to <code>myupdate()</code>. However, at one of our West Coast server, during execution inside of <code>myupdate()</code>, <code>ts</code> is auto-converted to PST <strong>2021-04-16 14:37:35.878694</strong> and has 3 extra digits at right.</p>
  <p>How to compare both in UTC and same precision?</p>