title: How can I check field values and then fire DQL
body: <p>I have some string type attributes on my custom type and a date type attribute <code>r_creation_date</code>. I want to use them all for search, so that as more fields have entered a value, the results will narrow down.</p>
  
  <p>I am using D2-Client 3.1 and using D2-Composer to build search property page and a query form (where I am specifying DQL).</p>
  
  <p>For filtering on string type fields I have formed this DQL:</p>
  
  <pre><code>select * from my_custom_type
      where (strattrib1 like '%$value(strattribinput1)%') and
            ("strattrib2" like '%$value(strattribintput2)%') and
            ("strattrib3" like'$value(strattribintput3)%') and
            ("strattrib4" like '%$value(strattribintput4)%') and
            ("strattrib5" like '%$value(strattribintput5)%') and
            ("strattrib6" like '%$value(strattribintput6)%')
  </code></pre>
  
  <p>Here <code>LIKE %</code> serves dual purpose:
  First of all whenever some string has entered it checks the occurrence of that string in that attribute.
  When nothing entered it considers all values in that attribute. This allows <code>AND</code>ing without explicitly checking for empty input. (as <code>$value(strattrib1)&lt;&gt;''</code>)</p>
  
  <p>Now I want to add the filter on date-type attribute <code>r_creation_date</code> to this query. However I cant get how can I do this, since I have to use <code>DATEDIFF()</code> function for date comparison and have to explicitly check for no input in <code>r_creation_date</code> as follows:</p>
  
  <pre><code>select * from my_custom_type
      where (strattrib1 like '%$value(strattribinput1)%') AND
            ("strattrib2" like '%$value(strattribintput2)%') AND
            ("strattrib3" like'$value(strattribintput3)%') AND
            ("strattrib4" like '%$value(strattribintput4)%') AND
            ("strattrib5" like '%$value(strattribintput5)%') AND
            ("strattrib6" like '%$value(strattribintput6)%') AND
            (DATEDIFF(day, "r_creation_date", DATE('$value(r_creation_date_intput)')) &gt;= 0 AND $value(r_creation_date_input)&lt;&gt;'')          
  </code></pre>
  
  <p>Here if user does not select any date for <code>r_creation_date_input</code>, <code>$value(r_creation_date_input)&lt;&gt;''</code> results in <code>FALSE</code> evaluating whole query to <code>FALSE</code>. Thus select query does not return anything.</p>
  
  <p><strong>Questions</strong></p>
  
  <ul>
  <li>How can I do this?</li>
  <li>Is there any other approach to do this?</li>
  <li>What is the standard approach?</li>
  <li>I want to add some more filters on date fields to same DQL. So is it possible?</li>
  <li>How can I validate input for string attributes? Can I write Java and attach it to D2-Client?</li>
  </ul>