Some time ago I posted a question on how to create a Select statement with a Where clause that needed to select on records that were between two dates. The problem was that the Date column in the table was a formated string and not a date.
It was suggested that I use the following structure:
Select Field1, Field2, Field3
From tablename
Where STR_TO_Date(Field3,'%m/%d/%Y')
Between '" & Format(txtStartDate.text,"yyyy-mm-dd") & "' AND '" & Format(txtEndDate.text,"yyy-mm-dd")
That structure worked in vb6 but it DOES NOT work in VB.NET
The user enters the start and end dates as a string in two textboxes
And wants to list all the records with dates between those two dates.
If anyone can give me the correct code for making this work I would appreciate it very much.
In my previous post I noted that I cannot change the column from a Char(10) to a date as this database is controlled and structured by a third party so I have no choice but to deal with the date in a string format.
Richard
It was suggested that I use the following structure:
Select Field1, Field2, Field3
From tablename
Where STR_TO_Date(Field3,'%m/%d/%Y')
Between '" & Format(txtStartDate.text,"yyyy-mm-dd") & "' AND '" & Format(txtEndDate.text,"yyy-mm-dd")
That structure worked in vb6 but it DOES NOT work in VB.NET
The user enters the start and end dates as a string in two textboxes
And wants to list all the records with dates between those two dates.
If anyone can give me the correct code for making this work I would appreciate it very much.
In my previous post I noted that I cannot change the column from a Char(10) to a date as this database is controlled and structured by a third party so I have no choice but to deal with the date in a string format.
Richard