Search a databse using date values
Hi,
I have vb form whitch contain two text boxes.
First one is Begindate
Second one is Enddate
If I want search a databse using begin date and end date how do i create sql statment.And also i want to display record in grid.
How to do that? Pl explain in simple english in details steps.
Thankx
shooter
Searching between two dates
You can make a query using a Sql string. You have to use format #Month/Day/year# in the sql String.
‘For example how to search between two dates begin an end.
Dim Sql as string
‘Me.txtBeginDate = Textbox with first Date
‘Me.txtEndDate = Textbox with end Date
Sql = “Select * from tbl... where Date(=field from tbl...) BETWEEN #" & Month(Me.txtBeginDate) & "/" & Day(Me.txtBeginDate) & "/" & year(Me.txtBeginDate) & "# And #" & Month(Me.txtEndDate) & "/" & Day(Me.txtEndDate) & "/" & year(Me.txtEndDate) & "#)”
I hope this will help You.