2016-01-20 66 views
0

我需要使用日期參數來設計報告(需要在英國的日期格式)參數在SSRS報告中未拿起NULL值顯示爲空白

Original date format: 2007-11-30 00:00:00.000 

So, I am using CONVERT(Date, Start_Date, 103): 2007-11-30 in my query. 

Data in Query: 

Start_Date   End_Date    Type 
---------------------------------------------------------------  NULL     2016-01-23     3 Month 
2009-08-11   2009-07-27     3 Month 
NULL     2015-10-13     3 Month 
NULL     2016-02-16     3 Month 
NULL     2015-12-28     3 Month 

現在在設計報告我使用這個數據集:

主要數據集查詢:

SELECT Col1, Col2, Start_Date, Target_Date, Col3 
FROM Table 
WHERE  (Col1 IN (@Param1)) 
AND (Col2IN (@Param2)) 
AND (Start_Date IN (@Start_Date)) AND (Target_Date IN (@Target_Date)) 

Now, When I run this report for Start_Date = 2009-08-11 and End_Date = 2009-07-27 and Type= 3 Month I get detailed data in report. 

However, When I select Start_Date = NULL and End_Date = 2016-02-16 and Type= 3 Month my report appears blank. I checked dataset and that too returns all values as NULL. 

您能否就這個問題提出建議/幫助?

問候, AR

回答

0
Start_Date = NULL 

不會work.You需要使用

Start_Date IS NULL 

ISNULL(Start_Date, 0) = 0 

所以是這樣的:

SELECT Col1, Col2, Start_Date, Target_Date, Col3 
FROM [Table] 
WHERE Col1 IN (@Param1) 
     AND Col2 IN (@Param2) 
     AND ISNULL(Start_Date, 0) IN (ISNULL(@Start_Date, 0)) 
     AND ISNULL(Target_Date, 0) IN (ISNULL(@Target_Date, 0));