Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations John Tel on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Filter DataView by Date Range

Status
Not open for further replies.

VBrian

Technical User
Mar 6, 2003
9
US
I am attempting to filter a dataview with the use of a Date Range. I am using two different DateTimePicker controls (dtpStartDate and dtpEndDate)

Here is the code I am using:

Dim _sDateRangeFilter as String

_sDateRangeFilter = "dOrderDate > " & dtpStartDate.Value.Date & " AND < " & dtpEndDate.Value.Date & ""

When I pass this value to my dataview.rowfilter I am getting this error:

Syntax error: Missing operand before '<' operator.

I've tried adding the "#" in the appropriate places, but get the same error.

I also tried using a "BETWEEN" operand but got an error indicating that that was not a valid operand.

Any help is greatly appreciated.

Thanks!

Brian

 
This should do the trick:

Code:
Dim _sDateRangeFilter as String

 _sDateRangeFilter = "dOrderDate > #" & dtpStartDate.Value.Date & "# AND [b]dOrderDate[/b] < #" &  dtpEndDate.Value.Date & "#"
 
Thanks dalchri!

That's all it took! Working like a charm.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top