如何使用linq减去日期并获得没有天数 [英] how to subtract date and get no of days using linq

查看:66
本文介绍了如何使用linq减去日期并获得没有天数的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述









i想要计算没有天数,当记录插入到db今天为每条记录,并希望使用linq和c#

Hi,



i want to count no of days,when the record is inserted to db with today for every record and want to assign those value to the repeator using linq and c#

推荐答案

将这些值分配给转发器现在定义为linq语句之前的当前日期

define now as current date before the linq statement
DateTime now = DateTime.Now;


你的linq声明中的



in your linq statement

dates = System.Data.Objects.SqlClient.SqlFunctions.DateDiff("dd", n.CreatedDateTime, now)


这篇关于如何使用linq减去日期并获得没有天数的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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