This is a migrated thread and some comments may be shown as answers.

How to conditionally display field data in a specific date range?

3 Answers 285 Views
Report Designer (standalone)
This is a migrated thread and some comments may be shown as answers.
Ian
Top achievements
Rank 1
Ian asked on 12 Aug 2014, 08:51 PM
I want to only show data that appears between the first and last days of last month, how might I do this?

My attempt (not working) is to use "between" logic and the C# methods AddMonths() and AddDays() in an "IIf" expression, showing another field if true and otherwise showing nothing if false:
= IIf(Fields.[Date Last Updated] Between Now().AddMonths(-1) And Now().AddDays(-1), Fields.[The Field I Want to Show], )

3 Answers, 1 is accepted

Sort by
0
Ian
Top achievements
Rank 1
answered on 14 Aug 2014, 07:23 PM

Ok, so I have gotten the above logic to compile with the help from this Telerik post, but is now displaying true or false:

= Fields.[The Field I Want to Display] In IIf(Fields.[Date Last Updated] Between Today().AddDays(CDbl(1 - Today().Day)).AddMonths(-1) And Today().AddDays(CDbl(- Today().Day)), Fields.[The Field I Want to Display], Null)

What I want is to filter Fields.[The Field I Want to Show] by Fields.[Date Last Updated], so that only values in the specified date-range are shown, otherwise skipping and not displaying all other values.

0
Accepted
Stef
Telerik team
answered on 15 Aug 2014, 07:41 AM
Hello Ian,

You can apply filtering:
  1. On data retrieving by parameterizing the data retrieval method. For example you can use a parameterized SQL query and map the SQL parameters to report parameters as in the Using Parameters with the SqlDataSource component and SqlDataSource Wizard  articles.
  2. In the data item you can add filter criteria specifying the ranges of data you would like to visualize in the report e.g.,  How to: Add filtering to Report.

Let us know if you need any further help.

Regards,
Stef
Telerik
 

Check out the Telerik Platform - the only platform that combines a rich set of UI tools with powerful cloud services to develop web, hybrid and native mobile apps.

 
0
Ian
Top achievements
Rank 1
answered on 19 Aug 2014, 09:45 PM
Ah, I was thinking in the wrong direction, thanks Stef! So I have isolated the values in the desired date-range in the SQL with this line of code added to my WHERE clause:
[My Date Here] BETWEEN DATEADD(MONTH, DATEDIFF(MONTH, 0, GETDATE())-1, 0) AND DATEADD(MONTH, DATEDIFF(MONTH, -1, GETDATE())-1, -1)

...based on this stackoverflow post.
Tags
Report Designer (standalone)
Asked by
Ian
Top achievements
Rank 1
Answers by
Ian
Top achievements
Rank 1
Stef
Telerik team
Share this question
or