0

我正在处理我的第一个 SSRS 报告项目,我有点困惑。我设计了自己的自定义报告,看起来与 Excel 中的发票模板一模一样。我的目标是按计划将这张发票/报告按月发送给客户。

但是,我的问题是将数据放入报告的字段中。我一直在使用表格来插入数据,但效果并不好。我使用以下查询创建了一个数据集:

SELECT CONVERT(VARCHAR(10), GETDATE(), 103) AS [DD/MM/YYYY]

该列:DD/MM/YYYY在我的数据库中不存在,但它只是获取当前日期。我收到一条错误消息:

字段的值表达式:SELECT CONVERT(VARCHAR(10), GETDATE(), 103) AS [DD/MM/YYYY] 包含错误。预期表达

对于报告的其他部分,我还想做一些其他的计算。所以我的问题是,我想放入表中的数据是否必须是数据库中的列?或者我可以使用 SSRS 创建它们吗?谢谢

4

1 回答 1

2

Please go through the link to understand how to create datasets and populate date on to your reports

Working with Datasets

The steps to create a dataset which retrieves current date is

1.Create a new dataset .Go to the data tab of your report and click on the drop down menu and select < new Dataset >

  1. A dialog box will appear where u need to enter the SQL query New DataSet

3.When u click ok ,you will see the newly created dataset in the dataset windows

DataSet

4.You can execute the sql query just to verify whether you are getting the current date or not .

5.Then in the Layout panel drag a Textbox in the header and then drag the column from the newly created dataset into it or you can write an expression

  =First(Fields!DD_MM_YYYY.Value, "GettingDate")

There is another way of getting the current date and time from SSRS itself instead of creating a dataset .You can use the inbuilt date and time functions in the SSRS .

Inbuilt Date Functions

于 2012-06-04T15:51:52.403 回答