Click here to Skip to main content
15,888,733 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Am new to coding and would be grateful if you guys can help me to solve this issue to trying to search between two dates ie "From Date" to "To Date" and display the results in Grid View.

What I have tried:

I am currently using this code
Me.GBCPVRBindingSource.Filter = "RECORDING DATE >= "’ & DateTimePicker1.Text & "’ and RECORDING DATE <= "’ & DateTimePicker2.Text & "’". But the error i get shows this - "missing operand after 'Date' operator.

Can someone please help me with this code and get it right.
Thanks
Posted
Updated 8-Feb-17 5:15am

1 solution

I notice there is white space in the column name of
RECORDING DATE
, wrap them in square brackets like this:
[RECORDING DATE]
.
Next, is the single quote for your datetimepickers, they are not nested correctly,
"’ & DateTimePicker1.Text & "
it should be
'" & DateTimePicker1.Text & "’
same for datetimepicker2
Lastly, instead of
DateTimePicker1.Text
it should be more appropriately
DateTimePicker1.Value.ToString()
Learn DateTimePicker.Value Property[^] vs DateTimePicker.Text Property[^]
 
Share this answer
 
v3
Comments
Kobby Adom 8-Feb-17 11:52am    
wow. that was really faster Peter. Thanks a lot. Its working well now. Am most grateful
Peter Leow 8-Feb-17 11:57am    
You are welcome.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900