How to select only date value No time in LINQ to SQL?

I need to have a query that lists all users according to the date value in the database. The problems are that the date format is 5/5/2009 4:30:12 in the database, 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 why I couldn't query it.

The request is like

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

Someone please check this issue.

Thanks in advance.

0


a source to share


1 answer


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 mark only the date:

u.SignupTime.Date = new DateTime(2009,5,5)

      

+1


a source







All Articles