我们的报告当前正在Access数据库中的宏内部运行,我们要将其转换为SSRS报告。
我想将Access查询转换为这些报告可以共享的共享数据集,因为我希望将这两个参数传递到此共享数据集中,但是我遇到了一个问题。
SELECT * FROM FROM ReportLog WHERE ClientName = [ClientNameParameter] AND
DateEntered BETWEEN getstartdatedaily() AND DATE() - 1
ORDER BY DateEntered;
上面的查询是我想要放入共享日期集的内容,但是对于每个报告,我会将查询传递给客户端名称(我不希望报告提示用户这个)并且getStartDateDaily是一个函数在Access中,我不知道如何将其转换为SSRS可以使用的东西。下面是运行该函数的代码,因为我不知道如何将其转换为SSRS报告可以使用的参数/函数。
Public Function getStartDateDaily() As Date
Dim startDate As Date
Dim endDate As Date
If Weekday(Date) = 2 Then
startDate = Date - 3
Else
startDate = Date - 1
End If
getStartDateDaily = startDate
End Function
非常感谢任何帮助。
答案 0 :(得分:0)
Northwind隐喻示例
Use Northwind
Go
Select * from
(
SELECT [OrderID]
,[CustomerID]
,[EmployeeID]
,[OrderDate]
,[RequiredDate]
,[ShippedDate]
,[ShipVia]
,[Freight]
,[ShipName]
,[ShipAddress]
,[ShipCity]
,[ShipRegion]
,[ShipPostalCode]
,[ShipCountry]
,DATEPART(dw,[OrderDate]) as MyDATEPART
, StartDateDaily =
CASE
WHEN DATEPART(dw,[OrderDate]) = 2 THEN DATEADD(d, -3, CURRENT_TIMESTAMP)--Date - 3
ELSE DATEADD(d, -1, CURRENT_TIMESTAMP) -- Date - 1
END
FROM [Northwind].[dbo].[Orders]
) as derived1
Where OrderDate between StartDateDaily and DATEADD(d, - 1, CURRENT_TIMESTAMP)
以上作品。
我对你的猜测:(提示,暂时注释掉下面的where子句,查看等式的计算值(MyDATEPART和StartDateDaily)并在必要时调整它们)
Select * from
(
SELECT *
,DATEPART(dw,DateEntered) as MyDATEPART
, StartDateDaily =
CASE
WHEN DATEPART(dw,DateEntered) = 2 THEN DATEADD(d, -3, CURRENT_TIMESTAMP)
ELSE DATEADD(d, -1, CURRENT_TIMESTAMP)
END
FROM ReportLog
) as derived1
Where DateEntered between StartDateDaily and DATEADD(d, - 1, CURRENT_TIMESTAMP)