show date range of QUERY in report header using main body SQL

  • Hello there I am struggling to find this topic answered anywhere

    I have a report that extracts patient records including the following SQL for date ranges:

    Between

    DATEADD(week, DATEDIFF(week,0,DATEADD(week,-1,getdate())), 0)

    AND

    dateadd(ms,-3,DATEADD(week, DATEDIFF(week,0,getdate() ), 0))

    This gives me the start date and end date of the previous week when the report was run. Great. I now want to include two text boxes in the report layout view (in header) to display the first and last day of the week in question (in other words i want to show the from and too dates in the header).

    I am not getting very far at the moment. All I have managed to do is display the min and max dates of the data in the table. This is only good if the first and last day have any activity which they do not always.

    Can anyone help?

    Will be much appreciated.

  • just add the two dates to the resultset - means adding two dates to every row though. Could also include a new datasource which just has those dates - that's if you want to keep the calculation in the database.

    It's probably easier if you pass the dates from the report as parameters then you can use those parameters in the header.

    Could also just do the calculation again in the report.


    Cursors never.
    DTS - only when needed and never to control.

Viewing 2 posts - 1 through 1 (of 1 total)

You must be logged in to reply to this topic. Login to reply