Click here to Skip to main content
11,813,379 members (69,727 online)
Rate this: bad
Please Sign up or sign in to vote.
See more: ASP .NET
My database has stored the date and time value i.e., with datatype Datetime.
I use Entity framework.
I want to check the fields with given date and extract only those records.

var query = from h in test.sample
where h.BDate.Value.Date==calender1.selectedDate.Date
select h;

The above code is not working.

I also used entityfunctions.truncatetime() whiich also does not favours me.

help me to extract only date from datetime datatype.

Posted 28-Feb-13 2:59am
ThePhantomUpvoter at 28-Feb-13 9:08am
Try your query with one = and see what happens.
sri senthil kumar at 1-Mar-13 7:50am
check whether ToShortDateString() helps you...
lindam88 at 8-Mar-13 21:30pm
for different date formats visit this-->
Rate this: bad
Please Sign up or sign in to vote.

Solution 1

try this link...
Rate this: bad
Please Sign up or sign in to vote.

Solution 2

you can use a format string

DateTime time = Date Time.Now;
String format = "MMM ddd d HH:mm yyyy";

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
0 Abhinav S 270
1 CHill60 180
2 KrunalRohit 154
3 Palash Mondal_ 145
4 Sergey Alexandrovich Kryukov 140
0 OriginalGriff 3,877
1 KrunalRohit 2,496
2 CPallini 2,240
3 Maciej Los 2,205
4 ppolymorphe 1,750

Advertise | Privacy | Mobile
Web02 | 2.8.151002.1 | Last Updated 13 Mar 2013
Copyright © CodeProject, 1999-2015
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100