title: Delete where date is 30 days back from now SQL Android
body: <p>Hello Im trying to delete all the records from my table which are 30 days old from now.</p>
  
  <p>The date is saved as <code>TIMESTAMP</code> as <code>YYY-MM-DD hh:mm:ss</code></p>
  
  <p>My table:</p>
  
  <pre><code>    db.execSQL("CREATE TABLE IF NOT EXISTS " + TABLE_GYM_MESSAGES + " ("                    
              + COLUMN_MAIN_ID + " INTEGER PRIMARY KEY AUTOINCREMENT, " 
              + COLUMN_MESSAGE + " TEXT, "
              + COLUMN_MESSAGE_DATE + " TIMESTAMP, "
              + COLUMN_SENDER + " TEXT);");
  </code></pre>
  
  <p>In my code I use this:</p>
  
  <pre><code>String whereClause = COLUMN_MESSAGE_DATE +" &lt; DATE_SUB(NOW() , INTERVAL 30 DAY)";
  
  ourDatabase.delete(TABLE_GYM_MESSAGES, whereClause, null);
  </code></pre>
  
  <p>The error i get:</p>
  
  <pre><code>Caused by: android.database.sqlite.SQLiteException: near "30": syntax error (code 1): , while compiling: DELETE FROM gym_message_table WHERE gym_message_date &lt; DATE_SUB(NOW() , INTERVAL 30 DAY)
  </code></pre>
  
  <p>Thanks for helping</p>