title: Compare difference between two dates using JPA Criteria Query
body: <p>I am using MySQL as a backend for my application.</p>
  
  <p>I want to execute query below using JPA Criteria Query.</p>
  
  <pre><code>SELECT * 
  FROM table1 t1
  WHERE datediff(now(), t1.created) &gt;= 20;
  </code></pre>
  
  <p>Note: Type of <code>created</code> is <code>TIMESTAMP</code></p>
  
  <p>I want Criteria Query like:</p>
  
  <pre><code>CriteriaBuilder cb = getEntityManager().getCriteriaBuilder();
  
  // select
  CriteriaQuery&lt;Table1&gt; query = cb.createQuery(Table1.class);
  
  // from
  Root&lt;Table1&gt; root = query.from(Table1.class);
  
  // where
  List&lt;Predicate&gt; predicates = new ArrayList&lt;Predicate&gt;();
  
  // TODO: add expression for datediff(now(), t1.created) &gt;= 20
  
  query.where(cb.and(predicates.toArray(new Predicate[0])));
  </code></pre>
  
  <p>Can any one help?</p>
  
  <p>Thanks in advance.</p>