title: HQL Date difference in minutes
body: <p>I have an Entity class Foo</p>
  
  <pre><code>@Entity
  public class Foo {
     @Basic
     @Column("Date_From)
     Date dateFrom;
     //...
  }
  </code></pre>
  
  <p>I need to take difference between <code>date_From</code> and current date, then get <code>mod</code> of them.</p>
  
  <p>In sql it would be</p>
  
  <pre><code>DATEDIFF(MINUTE, ct.dateFrom, :date) % 120
  </code></pre>
  
  <p>But HQL does not support <code>DATEDIFF</code> function, I've tried to add it to dialect</p>
  
  <pre><code>registerFunction("DATEDIFF_MINUTE", new SQLFunctionTemplate(new CalendarDateType(), "DATEDIFF(minute, ?1,?2)"));
  </code></pre>
  
  <p>And use it <code>MOD(DATEDIFF_MINUTE(ct.dateFrom, :date), 120)</code>, but I get exception</p>
  
  <pre><code>No data type for node: org.hibernate.hql.ast.tree.MethodNode 
   +-[METHOD_CALL] MethodNode: '('
   |  +-[METHOD_NAME] IdentNode: 'DATEDIFF_MINUTE' {originalText=DATEDIFF_MINUTE}
   |  \-[EXPR_LIST] SqlNode: 'exprList'
   |     +-[DOT] DotNode: 'Foota0_.Date_From' {propertyName=dateFrom,dereferenceType=ALL,propertyPath=dateFrom,path=ct.dateFrom,tableAlias=Foota0_,className=ru.package.Foo,classAlias=ct}
   |     |  +-[ALIAS_REF] IdentNode: '(Foota0_.Date_Create, Foota0_.User_Create)' {alias=ct, className=ru.package.Foo, tableAlias=Foota0_}
   |     |  \-[IDENT] IdentNode: 'dateFrom' {originalText=dateFrom}
   |     \-[NAMED_PARAM] ParameterNode: '?' {name=date, expectedType=null}
  </code></pre>
  
  <p>How can I solve this problem?</p>