linqtosql查询日期问题 求解
linqtosqlGYMDataContext rsv = new linqtosqlGYMDataContext("Data Source=.;Initial Catalog=GYM;Integrated Security=True");
Table<Reservation> Res = rsv.GetTable<Reservation>();
var date = from d in Res where Convert.ToDateTime(d.St_Time).ToShortDateString() == Convert.ToDateTime(selectdate).ToShortDateString() select d.St_Time;
selectdate是我从calendar控件上取得日期,求解 查询表里同一日期哪里有错
------解决方案--------------------linqtosqlGYMDataContext rsv = new linqtosqlGYMDataContext("Data Source=.;Initial Catalog=GYM;Integrated Security=True");
Table<Reservation> Res = rsv.GetTable<Reservation>();
var date = from d in Res
where System.Data.Linq.SqlClient.SqlMethods.DateDiffDay(Convert.ToDateTime(d.St_Time),Convert.ToDateTime(selectdate))==0
select d.St_Time;
------解决方案--------------------
最好用
SqlMethods.DateDiffDay
http://msdn.microsoft.com/zh-tw/library/system.data.linq.sqlclient.sqlmethods.datediffday.aspx