title: Coerce string of timestamp OR interval to timestamp
body: <p>I have a field that specifies a timestamp in the future, an expiry for a record. I'd like to be able to accept a string timestamp or an interval representing the time from now. Is there some simple way to attempt to cast a string to an interval, if it succeeds then add it to <code>now()</code> otherwise cast it to a timestamp (with time zone)?</p>
  
  <p>Before it gets asked, yes I'm sure I could do it with a stored proc, I'm curious about if I could use some type of <code>COALESCE</code> style magick. If the answer is stored proc then so be it, I can write that one.</p>
  
  <hr>
  
  <p>Edit: Here is my implementation as a stored proc.</p>
  
  <pre><code>create or replace function
    timestamptz_in_or_at(input text) 
    returns timestamptz
    as $$
    begin
      begin
        return now() + input::interval;
      exception when others then
        return input::timestamptz;
      end;
    end;
  $$ language plpgsql
  </code></pre>