在日期时间中获取日期 [英] To fetch onlt date in Date time

查看:103
本文介绍了在日期时间中获取日期的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆