How to filter by date and do a Form's query by code?
<p>I have to do a Form query by code. The datasource table is <em>CustomVendTable</em>(is a custom table).
I open a <em>form</em> and in my <code>init</code> method I get the table caller : </p>

<pre><code>public void init ()
{
  VendTable = myVendTableCaller;
  myVendTableCaller = element.args().record();
// There is a dialog and get a date by a _Dialog_ and save in a date variable
  super();
}
</code></pre>

<p>In my data source I have a build a <strong>query</strong>. The table in my datasource is related whit VendTable. I filter by code my <em>DataSource</em> by myVendTableCaller.RecId and variable <strong>date</strong> <em>dateByDialog</em> inserted in the opening <em>dialog</em></p>

<p>My query is this:</p>

<pre><code>public void executeQuery()
{
query q = new Query();
QueryBuildRange qbr;
QueryBuildDataSource qbds ;
QueryRun queryRun;

qbds = q.addDataSource(tableNum(CustomVendTable) );

qbds.addRange(fieldNum(CustomVendTable, ValidFrom)).value(SysQuery::value( strFmt ("&lt;=%1 ", _dateByDialog)) ) ;
qbds.addRange(fieldNum(CustomVendTable, ValidTo)).value(SysQuery::value( strFmt ("&gt;=%1 ", _dateByDialog))) ;
qbds.addRange(fieldNum(CustomVendTable, Vendor )).value(SysQuery::value(myVendTableCaller.recId));

queryRun = new QueryRun (q);

CustomVendTable_ds.query(queryRun.query());

super();
}
</code></pre>

<p>*For information there is a <em>Table Relation</em> CustomVendTable.Vendor == VendTable.RecId</p>

<p>So, I have some problems! I think not to be able to make a correct <em>query</em> by date. The fields <strong>ValidFrom - ValidTo</strong> are <em>UTCdatetime</em> type.</p>

<p>1) I have to convert my _dateByDialog in UTC ? How to do ? It' s correct my query date way ?</p>

<p>Considering that the conversion is not impossible, my BIG problem is that by filtering by date, if I have only one record with recid same range and dates I can somehow see it, BUT if there are more record with these same characteristics (If I have 2 record) I don't see nothing! My Form Grid is void!</p>

<p>I have read that you should set the <em>Session date time</em> (<a href="https://technet.microsoft.com/en-us/library/aa571130.aspx" rel="nofollow">I'm talking about this</a> ) to have control over dates.</p>

<p>I still believe that I do not build my <em>Query</em> very well.</p>

<p>Do you have an idea how can I do ?</p>