开发者

time calculation within LINQ

I want a linq query to return a calculated timespan, i have used the timespan function before, but im not sure how to incorporate it into linq. Basically the linq is returning a datetime field which i开发者_如何学编程 want to subtract from the current datetime to get days and hours.

Any help appreciated!

Thanks


Maybe something like:

from s in something
select DateTime.Now.Subtract(s.DateField)


Sure, the code below returns a date opened field, i want to calculate how many days the case is open and put it into a gridview.

var query2 = from cs in db.tblCases where cs.date_closed.HasValue == false select new { cs.date_case_opened),

                         };

    gvReport.DataSource =
                query2.Select(o => new {o.time });

            gvReport.DataBind();
            lbCount.Text = "Days open: " + ???
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜