title: How to activate a trigger on a date
body: <p>How could I have a trigger that updates a certain field when the system reaches a certain date ?</p>
  
  <p>i.e. </p>
  
  <pre><code>+---------------------+  +-------------+
  |   Trains            |  |    Trips    |
  +---------------------+  +-------------+
  | id                  |  |  id         |
  | distanceTraveled    |  |  endDate    |
  |                     |  |  trainUsed  |
  |                     |  |  distance   |
  +---------------------+  +-------------+
  </code></pre>
  
  <p>Trains :</p>
  
  <ul>
  <li>train1, 0</li>
  <li>train2, 0</li>
  <li>train3, 0</li>
  <li>train4, 0</li>
  </ul>
  
  <p>Trips :</p>
  
  <ul>
  <li>1, 12:00:00 tomorrow, train1, 10</li>
  <li>2, 14:45:00 tomorrow, train3 ,20</li>
  <li>3, 02:15:00 after-tomorow ,train1, 15</li>
  </ul>
  
  <p>Execution :</p>
  
  <ul>
  <li>At 12:00:00 tomorrow, update the table train so the distanceTraveled    field for train1 comes to 10 </li>
  <li>At 14:45:00 tomorrow, update the table    train so the distanceTraveled field for train3 comes to 20 </li>
  <li>At    02:15:00 the day after-tomorrow, update the table train so the distanceTraveled    field for train1 comes to 25</li>
  </ul>
  
  <p>Final result in 2 days would be</p>
  
  <p>Trains :</p>
  
  <ul>
  <li>train1, 25</li>
  <li>train2, 0</li>
  <li>train3, 20</li>
  <li>train4, 0</li>
  </ul>