时间比较

适用sqlserver

public static int? DateDiff(string datePartArg, System.DateTimeOffset? startDate, System.DateTime? endDate)
System.Data.Entity.SqlServer.SqlFunctions 的成员

System.Data.Entity.SqlServer.SqlFunctions.DateDiff("day", d.endtime.Value, sel_strtime)

例子:

predicate = predicate.And(d => System.Data.Entity.SqlServer.SqlFunctions.DateDiff("day", '2017-04-01', '2017-04-21') <= 0);

System.Data.Entity.SqlServer.SqlFunctions.DateDiff("dd", "2017-04-01", "2017-04-21") == 20天

oracle可直接比较

posted @ 2017-02-04 14:57  鞍山老菜鸟  阅读(148)  评论(0编辑  收藏  举报