views:

348

answers:

1

I need to have a query which list all the user according to the date value in the database. Problems is this, in the database the date format is 5/5/2009 4:30:12 but I want to compare with 5/5/2009. I think the value of the based date is 5/5/2009 12:00:00 and that's why I couldn't query it.

The query is something like

dim db = new databcontext dim user = from u in db.datacontext where u.signUpTime = 5/5/2009 select u.

May someone please check this problem.

Thanks in advance.

+1  A: 

Your theory is correct. You should either use a range in your where clause:

u.SignupTime >= new DateTime(2009,5,5,0,0,0) AndAlso _
u.SignupTime < new DateTime(2009,5,6,0,0,0)

or check only the date:

u.SignupTime.Date = new DateTime(2009,5,5)
Mehrdad Afshari
I think I agree, the .Date property is the date/time at midnight.
kenny
+1 Maybe explain that SignupTime.Date returns only the date part of SignupTime
Andomar
Thanks you so much. It works so perfect ..
Vicheanak