Search code examples
asp.netvb.netdataview

Missing operand after '00' operator


I'm trying to filter a dataview using a DataView RowFilter. I want to filter out data based on two date values checked on one column:

Dim dtFuture As Date = DateAdd(DateInterval.Month, 6, Today)
dv.RowFilter = "ValidUntil >" & dtFuture.ToString & "AND ValidUntil > " & Today.ToString

I am getting the error Syntax error: Missing operand after '00' operator.. Not sure whether I am doing it the right way.


Solution

  • I think you need to wrap the dtFuture values in single quotes :

    Dim dtFuture As Date = DateAdd(DateInterval.Month, 6, Today)
    dv.RowFilter = "ValidUntil >'" & dtFuture.ToString() & "' AND ValidUntil > '" & Today.ToString() & "'"
    

    ToString should also have brackets, and you need a space before the AND.