How the ssrs expressions works for DateDiff?

I am currently working on SSRS reports there is one column i.e Holding period where we actually calculate for

 

Since the purchase date, how many days the company is on hold in our database

 

and ssrs expression is

=DateDiff(DateInterval.Day, Fields!BuyDate.Value, First(Fields!Date.Value, "DailyPosition"))
 

I think i am performing a wrong calculation, Could any one help to execute correct calculation.

 

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

 

Lets discuss an 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

Mentioned query results as 293 select DATEDIFF (day,'2012-03-13 00:00:00.000','2012-12-31 00:00:00.000')

 

Above result is wrong as my holding period is 126 days only

 

please help me to correct the expression.

Answered by Amit verma

Basically, ssrs datediff returns the number of date and time boundaries crossed between two specified dates.

You can try something like this:

=Floor(DateDiff("s",CDATE("04/03/2016 08:48:53 AM"),
CDATE("07/03/2016 11:24:04 AM")) / 86400) & ":" &
Format(DateAdd("s", DateDiff("s",CDATE("04/03/2016 08:48:53 AM"),
CDATE("07/03/2016 11:24:04 AM")), "00:00:00"), "HH:mm:ss")

Your Answer

Interviews

Parent Categories