title: SQLite trigger Issue
body: <p>I have a trigger on a table which gets triggered on any new insert...Here is the code for the trigger. This trigger has to calculate duration in seconds and insert the record in the table.</p>
  
  <pre><code>CREATE TRIGGER duration_trigger 
  BEFORE INSERT on StudentData 
  BEGIN 
  UPDATE StudentData set duration = (select cast( (julianday(enddatetime) - julianday(startdatetime) ) *24 * 60 *60 as integer) from StudentData); 
  END
  </code></pre>
  
  <p>In <code>StudentsData</code> table <code>Duration</code> column is defined as <code>INTEGER</code>,
  <code>StartDatetime</code> and <code>EndDatetime</code> are defined as <code>TEXT</code></p>
  
  <p>Here comes my issue.</p>
  
  <p>Trigger gets triggered, but the value in Duration column is always <code>7</code></p>
  
  <p>When I execute the same select query that is in the the trigger in a SQL tool, it gives me correct duration in seconds. Trigger on the database is not producing the same result...what could be the issue?</p>
  
  <p>I am also attaching screenshots of the trigger data in the table and select query results from same table.</p>
  
  <p>Table results after trigger.</p>
  
  <p><a href="https://i.stack.imgur.com/0raPv.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/0raPv.png" alt="Table results after trigger."></a></p>
  
  <p>Select Query results</p>
  
  <p><a href="https://i.stack.imgur.com/gh8IM.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/gh8IM.png" alt="Select Query results."></a></p>