在日期时间中获取日期 [英] To fetch onlt date in Date time
问题描述
Hai,
我的数据库存储了日期和时间值,即数据类型为Datetime。
我使用实体框架。
我想检查给定日期的字段并仅提取那些记录。
var query =来自test.sample中的h
其中h。 BDate.Value.Date == calender1.selectedDate.Date
选择h;
以上代码无效。
我也使用了entityfunctions.truncatetime(),但也不赞成我。
帮我提取日期datetime数据类型。
问候,
K.Priya ...
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...
推荐答案
试试这个链接...
http://stackoverflow.com/questions/3305972/extracting-yyyy-mm- dd-formated-date-from-datetime-datatype-in-t-sql
try this link...
http://stackoverflow.com/questions/3305972/extracting-yyyy-mm-dd-formated-date-from-datetime-datatype-in-t-sql
你可以使用格式字符串
日期时间=日期Ti me.Now;
String format =MMM ddd d HH:mm yyyy;
Console.WriteLine(time.ToString(format));
you can use a format string
DateTime time = Date Time.Now;
String format = "MMM ddd d HH:mm yyyy";
Console.WriteLine(time.ToString(format));
这篇关于在日期时间中获取日期的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!