Dates with VB.Net and SQL

ediguy

Member
Joined
Jul 15, 2005
Messages
8
Programming Experience
10+
Hi everyone,

I am trying to figure out how to get a record from a SQL table (Microsoft) that is keyed by a datetime data type.

I want to do a simple query to match the day, but I am getting nowehere fast.

Any idea how to query a datetime datatype in SQL from a select statement in VB so that I can get a specific date?

Thanks!
 
SELECT *
FROM yourTable
WHERE yourField BETWEEN SomeDate AND DATEADD(s, -1, DATEADD(d, 1, SomeDate))

SomeDate would be the date you are looking for. This will add a day to the date, then subtract one second. So if you hace someDate set as '9/12/2005' your range would be '9/12/2005 0:00:00' through '9/2/2005 23:59:59'

-tg
 
Back
Top