Reputation: 693
I have a DataTable (dt) as
StartDate EndDate Price
1 3 10
4 6 12
7 10 16
11 15 20
I want to filter the Values from dates between fromdate= 2 and todate=8.
so i am expecting the result to be
StartDate EndDate Price
1 3 10
4 6 12
7 10 16
I have used the vb Datatable Select as->
dt.Select("StartDate <= #" & fromdate& "# And EndDate >= #" & todate& "#")
but i am not getting the result. Can u please suggest me..
Upvotes: 2
Views: 1782
Reputation: 43023
Your query should be like that:
dt.Select("StartDate <= #" & todate & "# And EndDate >= #" & fromdate & "#")
to find records that overlap with your range.
Upvotes: 2
Reputation: 48558
it should be
dt.Select("StartDate >= " & fromdate & " And EndDate <= " & todate)
Two problems
Your operator were all wrong. You were taking startdate less than 2 and greater than 8 whereas it should be startdate greater than 2 and less than 8
Morever no need for # assuming that columns are of integer type.
Upvotes: 1