Search code examples
sqlsql-server-2008reporting-servicesssrs-2008

How to add 2 columns in SSRS expressions with calculation?


I have a table customerTrans with two columns order_date as DateTime, and days_of_arrival as Int. I need to make an expression to display the expected date like:

(order_date+days_of_arrival) = expected_date

For example, if customer order_date is 12/15/2015 and days_of_arrival = 7 I need to show the expected_date as 12/22/2015.

I used the DateAdd() function in my expression but it doesn't work for me.

=DateAdd("d", sum(days_of_arrival), Fields!payment_date)

How can I calculate the expected date?


Solution

  • The problem is that you are using SQL command syntax but Reporting Services uses VBA. DateAdd exists in SSRS but uses DateInterval properties, not the SQL "d" so the expression you want is:

    =DateAdd(DateInterval.Day, Fields!days_of_arrival.Value, Fields!order_date.Value)