在报告查看器中检索最近30天 [英] Retrieving last 30 days in report viewer

查看:72
本文介绍了在报告查看器中检索最近30天的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的asp.net C#网页中有一个报告视图,它显示SQL Server 2012中表(table1)的结果。该表每天都会获得一个条目(新行)。我想在报表查看器中仅显示该表的最后30天。我正在使用Visual Studio Community 2015,我尝试在设计模式中选择(行),并从Tablix属性我转到过滤器选项,并尝试按(coloumn1)排序显示最近30天。我通过选择> = 12-26-17手动获取它,但是使用公式代替日期不起作用。

请指教。谢谢。



我的尝试:



Talbix Properties下我选择按两个日期排序:



=字段!CNBDATE.Value

之间



12/26/2016 00:00:00

01/26/2017 00:00:00



我也试过以下代码(但它没有用)

DATEADD(DAY,-30,GETDATE())

I have a report view in my asp.net C# web page that displays results from a table (table1) in SQL Server 2012. The table gets an entry (new row) everyday. I want to display only the last 30 days from that table in the report viewer. I am using Visual Studio Community 2015 and I tried selecting the (row) in design mode and from the Tablix Properties I went to the "Filter" option and was trying to sort by (coloumn1) for the last 30 days to be displayed. I get it manually by selecting >= 12-26-17 but putting a formula in lieu of a date does not work.
Please advise. Thank you.

What I have tried:

Under Talbix Properties I have selected to sort by two dates:

=Fields!CNBDATE.Value
Between

12/26/2016 00:00:00
01/26/2017 00:00:00

I have also tried the following code (but it did not work)
DATEADD(DAY, -30, GETDATE())

推荐答案

将过滤器添加到查询中,而不是报告:

Add the filter to your query, rather than the report:
SELECT
    CNBDATE,
    ...
FROM
    YourTable
WHERE
    CNBDATE >= DateAdd(day, -30, Convert(date, GetDate()))
;


谢谢,我之前做过这个我以为我可以在网络端运行sql命令而不是创建另一个视图。我很感激您的反馈意见。
Thanks, I did this before but thought I would be able to run the sql command on the web side rather than create another view. I appreciate the feedback.


这篇关于在报告查看器中检索最近30天的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆