Click here to Skip to main content
15,885,309 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
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())
Posted
Updated 30-Jan-17 6:00am

Add the filter to your query, rather than the report:
SQL
SELECT
    CNBDATE,
    ...
FROM
    YourTable
WHERE
    CNBDATE >= DateAdd(day, -30, Convert(date, GetDate()))
;
 
Share this answer
 
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.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900