title: How to Set a calculated timestamp as a default value MySQL
body: <p>I am trying to create a table that sets an expiry date within 2 weeks of having been created. The next select statement gives me that record:</p>
  
  <pre><code> (SELECT TIMESTAMPADD(WEEK,2,(CURRENT_TIMESTAMP)));
  </code></pre>
  
  <p><strong>| 2014-04-21 18:08:52 |</strong></p>
  
  <p>But DEFAULT on create table does not allow me to put any expression:</p>
  
  <pre><code>create table test (somename varchar(32), expiry TIMESTAMP DEFAULT (SELECT TIMESTAMPADD(WEEK,2,(CURRENT_TIMESTAMP))));
  </code></pre>
  
  <p>How can achieve this?
  --UPDATE - 
  I TRY this trigger but my syntax is wrong:</p>
  
  <blockquote>
    <p>CREATE TRIGGER expiryset AFTER INSERT ON test BEGIN DECLARE exp
    TIMESTAMP; SET @exp := (SELECT
    TIMESTAMPADD(WEEK,2,(CURRENT_TIMESTAMP)));  UPDATE test SET expiry  =
    @exp WHERE somename = ; END;</p>
  </blockquote>
  
  <p><strong>this works but i need to get somename value/column of the insert before the trigger....how can i get this?</strong></p>