datetime filters on report subcription

lawrence whittemore asked on February 8, 2023 22:40

I have a start and end date parameter on a report that defaults to get the last 2 weeks with a macro. When I create a subscription, will those update based on the current date and time when the subscription sends or will it keep the date and time field that it shows in the subscription when it is saved?

or is it better to just create the report to have the date and time all happen in the sql query and not use the parameters?

Recent Answers


Brenden Kehren answered on February 9, 2023 03:45

It will be based on the dates you entered at the time of the subscription. I'd set the default property value to a macro like {% DateTime.Now.AddDays(-30) %} or something of the like and see if this gets you the results you're looking for.

0 votesVote for this answer Mark as a Correct answer

lawrence whittemore answered on February 9, 2023 12:48

Initially I did use the macro as the default date and time, but when I created the subscription it set the parameters to the dates and not the macro so I wasn't sure if it would work when the report sent every 2 weeks. I ended up just coding it into the sql query. In our 12+ years of using kentico we've never sent reports automatically so i wasn't really sure how it would work.

0 votesVote for this answer Mark as a Correct answer

Not Applicable answered on February 9, 2023 20:53

Name the parameters in your report FromDate and ToDate (the names are important) and set the data type to Date and Time for both. As the default values for the parameters, you can use the macro Brenden mentioned and for today {% DateTime.Now %}.

When you create a subscription for that report, the FromDate and ToDate parameters are not visible in the subscription parameters. But every time a subscriber receives an email, the macros are reapplied.

0 votesVote for this answer Mark as a Correct answer

Brenden Kehren answered on February 9, 2023 21:21

As I look back in our last report subscription we created, we used sequel statements directly in our sequel query that seem to give us the best result.

0 votesVote for this answer Mark as a Correct answer

   Please, sign in to be able to submit a new answer.