views:

33

answers:

2

Hi

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

+1  A: 

Maybe something like:

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

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: " + ???
DarkWinter