title: Attempting (and failing) to create user function for H2 database
body: <p>Our main database is MySQL.  </p>
  
  <p>Few queries are using fairly common <code>DATE_SUB($date, INTERVAL $duration $type)</code>.  </p>
  
  <p>We are running our tests over H2 database and the absence of <code>DATE_SUB()</code> function creates a problem.<br>
  We had an idea of creating a user H2 function to replicate MySQL behaviour - I had two separate attempts at that, both implementations existed and were mapped separately.</p>
  
  <pre><code>    CREATE ALIAS IF NOT EXISTS DATE_SUB FOR "xxx.yyy.Zzz.dateSubtract";
  
  public Zzz {
          ...
          public static Date dateSubtract(Connection connection, String dateValue, String formula) {
              return dateSubtractJava(dateValue, formula);
          }
  
          public static Date dateSubtract(Connection connection, String dateValue, String INTERVAL, String numberOfDateIntervals, String dateIntervalName) {
              return dateSubtractJava(dateValue, INTERVAL, numberOfDateIntervals, dateIntervalName);
          }
          ...
  }
  </code></pre>
  
  <p>unfortunately my attempts are failing with:  </p>
  
  <pre><code>org.h2.jdbc.JdbcSQLException: Syntax error in SQL statement 
  ...  
  DATE_SUB(?, INTERVAL 1[*] DAY)  
  expected "., (, [, ::, *, /, %, +, -, ||, ~, !~, NOT, LIKE, REGEXP, IS, IN, BETWEEN, AND, OR, ), ,";
  </code></pre>
  
  <p>It looks like H2 is NOT even attempting to use my user function but failing while trying to parse the SQL statement.  </p>
  
  <p>Did anybody manage to do something like that successfully? </p>