Click here to Skip to main content
Rate this: bad
good
Please Sign up or sign in to vote.
See more: ASP .NET
Hai,
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.
 

Regards,
K.Priya...
Posted 28-Feb-13 3:59am
Comments
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-->http://ww2.technoreader.com/?folio=7POJ4E717
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 1

try this link...
 
http://stackoverflow.com/questions/3305972/extracting-yyyy-mm-dd-formated-date-from-datetime-datatype-in-t-sql
  Permalink  
Rate this: bad
good
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";
Console.WriteLine(time.ToString(format));
  Permalink  

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

  Print Answers RSS
0 DamithSL 320
1 OriginalGriff 155
2 Peter Leow 115
3 Afzaal Ahmad Zeeshan 114
4 deepakdynamite 110
0 OriginalGriff 7,510
1 DamithSL 5,519
2 Sergey Alexandrovich Kryukov 5,044
3 Maciej Los 4,961
4 Kornfeld Eliyahu Peter 4,514


Advertise | Privacy | Mobile
Web02 | 2.8.141223.1 | Last Updated 13 Mar 2013
Copyright © CodeProject, 1999-2014
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