display image on a report based on two date

Posted by Yongwei Xing on Stack Overflow See other posts from Stack Overflow or by Yongwei Xing
Published on 2010-03-29T08:05:52Z Indexed on 2010/03/29 8:13 UTC
Read the original article Hit count: 207

Hi all

I am using sql server 2005 reporting service to generate report base on a database. There are two columns which are datetime type ColumnA and ColumnB. The report would display a KPI image on this report by comparing these two columns.Below is the expression for selecting image

SWITCH(DateDiff("d",Fields!ColumnA.Value,Fields!ColumnB.Value)<0,"kpi_r",
       DateDiff("d",Fields!ColumnA.Value,Fields!ColumnB.Value)>0,"kpi_g",
       DateDiff("d",Fields!ColumnA.Value,Fields!ColumnB.Value)=0,"kpi_y")

For most of the records, the image is correct. Only for one record, the result is very strange. For this record

ColumnA=2010-04-23 08:00:00 ColumnB=2010-04-22 17:00:00 It would display kpi_r, it displayed kpi_y. I have checked the value of DateDiff(d,Fields!ColumnA.Value,Fields!ColumnB.Value) in the SSMS, the value is -1. Why does it display kpi_y? Does anyone meet this problem before?

Best Regards,

© Stack Overflow or respective owner

Related posts about sql-server

Related posts about reporting-services