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

4 posts, 1 answers
  1. Ian
    Ian avatar
    11 posts
    Member since:
    Apr 2014

    Posted 12 Aug 2014 Link to this post

    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], )
  2. Ian
    Ian avatar
    11 posts
    Member since:
    Apr 2014

    Posted 14 Aug 2014 Link to this post

    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.

  3. DevCraft banner
  4. Answer
    Stef
    Admin
    Stef avatar
    3036 posts

    Posted 15 Aug 2014 Link to this post

    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.

     
  5. Ian
    Ian avatar
    11 posts
    Member since:
    Apr 2014

    Posted 19 Aug 2014 in reply to Stef Link to this post

    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.
Back to Top