title: How to create a unique constraint on the date of a timestamp
body: <p>In postgresql (9.2), I have a table with:</p>
  
  <pre><code>  tservice         timestamp without time zone NOT NULL,
    patient_recid    integer NOT NULL
  </code></pre>
  
  <p>I wish to create a unique constraint on the <em>date</em> of tservice, something like:</p>
  
  <pre><code>  constraint service_unique UNIQUE (patient_recid, tservice::date)
  </code></pre>
  
  <p>which produces a syntax error at the date cast.</p>
  
  <p>How is this best done in PostgreSQL?</p>
  
  <p>TIA</p>