Click here to monitor SSC
SQLServerCentral is supported by Red Gate Software Ltd.
 
Log in  ::  Register  ::  Not logged in
 
 
 
        
Home       Members    Calendar    Who's On


Add to briefcase

How the ssrs expressions works for DateDiff? Expand / Collapse
Author
Message
Posted Monday, April 15, 2013 10:48 AM
SSC Journeyman

SSC JourneymanSSC JourneymanSSC JourneymanSSC JourneymanSSC JourneymanSSC JourneymanSSC JourneymanSSC Journeyman

Group: General Forum Members
Last Login: Thursday, January 2, 2014 1:30 AM
Points: 90, Visits: 199
I'm working on SSRS reports there is on column i.e Holding period where we actually calculate for

how many days the company is hold in our database (we compare with buy date)

and ssrs expression is

=DateDiff(DateInterval.Day, Fields!BuyDate.Value, First(Fields!Date.Value, "DailyPosition"))
Which is coming wrong could any one help to execute correct calulation.

Buy date is a normal date column from table , and "DailyPosition" is my dataset name from ssrs report.

for example Company ABC buy date is 2012-03-13 00:00:00.000 and last parameter date is 2012-12-31 00:00:00.000

below query giving me result as 293 select DATEDIFF (day,'2012-03-13 00:00:00.000','2012-12-31 00:00:00.000')

which is wrong as my holding period is 126 days only

please help me to correct the expression.
Post #1442409
Posted Monday, April 15, 2013 11:06 AM


SSC-Insane

SSC-InsaneSSC-InsaneSSC-InsaneSSC-InsaneSSC-InsaneSSC-InsaneSSC-InsaneSSC-InsaneSSC-InsaneSSC-InsaneSSC-Insane

Group: General Forum Members
Last Login: Today @ 8:19 PM
Points: 23,286, Visits: 32,012
ashuthinks (4/15/2013)
I'm working on SSRS reports there is on column i.e Holding period where we actually calculate for

how many days the company is hold in our database (we compare with buy date)

and ssrs expression is

=DateDiff(DateInterval.Day, Fields!BuyDate.Value, First(Fields!Date.Value, "DailyPosition"))
Which is coming wrong could any one help to execute correct calulation.

Buy date is a normal date column from table , and "DailyPosition" is my dataset name from ssrs report.

for example Company ABC buy date is 2012-03-13 00:00:00.000 and last parameter date is 2012-12-31 00:00:00.000

below query giving me result as 293 select DATEDIFF (day,'2012-03-13 00:00:00.000','2012-12-31 00:00:00.000')

which is wrong as my holding period is 126 days only

please help me to correct the expression.


Not sure how 293 is wrong as it is the number of days between '2012-03-13 00:00:00.000' and '2012-12-31 00:00:00.000'.

Without more information I'm not sure how we can help.



Lynn Pettis

For better assistance in answering your questions, click here
For tips to get better help with Performance Problems, click here
For Running Totals and its variations, click here or when working with partitioned tables
For more about Tally Tables, click here
For more about Cross Tabs and Pivots, click here and here
Managing Transaction Logs

SQL Musings from the Desert Fountain Valley SQL (My Mirror Blog)
Post #1442416
« Prev Topic | Next Topic »

Add to briefcase

Permissions Expand / Collapse