Recently, I am building a report using the SQL Server reporting service. I met a problem about datediff. There are two datetime values 2010-04-23 08:00:00 and 2010-04-22 17:00:00. If you use the TSQL built-in function DATEDIFF to check the value in SQL Server Management Studio like below:
DATEDIFF(d,'2010-04-23 08:00:00','2010-04-22 17:00:00')You would get the -1.
But, if you use the DATEDIFF in the ReportBuilder, it would return 0. I guess that Within SSMS if you cross midnight you have triggered a day boundary so it get -1. in ReportBuilder it is looking for 24 hours to be between the two values so it gets 0.
No comments:
Post a Comment