I just need to compare a date entered by a user to a DateTime
stored in my database. I have tried converting the DateTime
to Date
like this:
select CONVERT(date, startdate) from myTable
However, when the information is shown in my GridView
, there is still a time attached to the date. (The time shown is 12:00:00.) What can I do to either convert the DateTime
to just a Date
when the information is pulled from the database, or compare a Date
to a DateTime
? Why is there still a time shown, even though I converted the DateTime
to Date
?
**Update
It may be worth noting that I can run the query that populates my GridView
in SQL Server Management Studio and the results shown are what I expect-- no time is in the date. I think the problem must be in VB.NET...
**More information
I am having the user fill out a form that will be used to search the database for relevant results. However, as it stands, no results are being returned because the user enters a normal date in the Date
field on the form, while the field in the database is a DateTime
. This is why I need to know how to convert it.
**Requested Information
Here is the query I'm using:
select convert(date, startdate) as startdate, CONVERT(date, completedate) as completedate
from myTable
Here is the result set in SQL Server Management Studio (no times):
Here is the result set in the grid (shows times):
I obviously omitted information from the database, but the information shown is all I'm worried about. I had to omit confidential information.