Search code examples
report-viewer2010

Calculating days from two dates


So i have a report viewer showing data but in one of my columns i want to show the calculated days based off the previous two columns of dates in an expression property i can apply for the text box. Example of what i am trying to do

8/1/2011 8/19/2011 18 days


Solution

  • (endDate - startDate).TotalDays 
    

    Substraction on two DateTimes produces TimeSpan object, which has TotalDays property

    Or try DateDiff("d", endDate, startDate) (for Visual Basic only)