我需要使用日期参数设计报告(需要采用英国日期格式)
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 :(得分:0)
Start_Date = NULL
无法使用。您需要使用
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));