PowerBuilder – Datawindow Filter on a datetime column

Posted on Friday, November 5th, 2010 at 8:20 pm in

A question came in on the TekTips Powerbuilder forum regarding filtering on a datetime column in a datawindow. Basically the problem was a ‘type mismatch’ error when trying to filter this type of column. This is how the author was setting the filter:

<code> ls_filter = "ls_column_name= '11/10/2010 12:30:00'"
or ls_filter = "ls_column_name= '" + ls_dateval + "'"</code>
The answer is to convert the column data value to the same format as being tested for.

<pre name="code" class="VB">ls_filter = "string(" + ls_column_name + ", 'mm/dd/yyyy hh:mm:ss)' = '11/10/2010 12:30:00'" 
or ls_filter = "string(" + ls_column_name + ", 'mm/dd/yyyy hh:mm:ss)' = '" + ls_dateval + "'"
You might also be interested in