madan
madan

Reputation: 81

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?

Upvotes: 1

Views: 675

Answers (2)

Chris Latta
Chris Latta

Reputation: 20560

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)

Upvotes: 1

Marco Bong
Marco Bong

Reputation: 690

Add this to your SQL query:

DATEADD(dd, days_of_arrival, order_date) as expected_date

Upvotes: 1

Related Questions