{"id":196,"date":"2007-07-31T01:44:00","date_gmt":"2007-07-31T01:44:00","guid":{"rendered":"\/lisa\/post\/2007\/07\/31\/Generalizing-date-related-report-parameters.aspx"},"modified":"2007-07-31T01:44:00","modified_gmt":"2007-07-31T01:44:00","slug":"generalizing-date-related-report-parameters","status":"publish","type":"post","link":"https:\/\/spacefold.com\/lisa\/2007\/07\/31\/generalizing-date-related-report-parameters\/","title":{"rendered":"Generalizing date-related report parameters"},"content":{"rendered":"<p>\nIn a recent <a href=\"http:\/\/forums.microsoft.com\/MSDN\/ShowPost.aspx?PostID=1936651&amp;SiteID=1\" title=\"MSDN post\">MSDN forum question about how to Increment a Date in a Reporting Services subscription<\/a>, I described how I approach the problem of a report that has been designed with one or more datetime parameters, and now has to be run on a schedule.&nbsp; Here&#39;s an excerpt from that answer, which I thought I&#39;d expand on a bit here, because my actual method goes further:&nbsp;\n<\/p>\n<p><\/p>\n<blockquote>\n<p>\n\tOne way I often have to handle this is to have params that are date based (for interactive use) and also an alternative set of parameters that are &quot;DaysOffset&quot; based.&nbsp; The latter are of integer type, and are typically used for subscriptions.&nbsp; They all work of DATEDIFF() with GETDATE() internally in my sprocs.\n\t<\/p>\n<p>\n\tLet&#39;s say I have a report that shows shipping orders.&nbsp; It might have two params, StartDate and EndDate, and an integer param ShipDateDaysOffset.&nbsp; If a user says &quot;I want to receive the shipping orders report once a week with all the orders that shipped that week&quot;, I can set up the args as NULL, NULL, -7 in the subscription.\n\t<\/p>\n<p>\n\tDon&#39;t necessarily hide these integer offset params from your interactive users.&nbsp; You&#39;ll be surprised at how often they&#39;ll go for the convenience of using a number of days offset, rather than thinking about dates.&nbsp; You need to make sure they understand that these are *alternatives* &#8212; and which params (usually the dates) take precedence if both sets are filled out.\n\t<\/p>\n<p>\n\tA good prompt for this type of param is something like &quot;Days from now&quot;.&nbsp; But where the event typically took place in the past (like in my example) you can use a prompt such as &quot;Days ago&quot; instead, to avoid users having to type a negative number to get it right, and just set up the DATEDIFF() the other way around &lt;s&gt;.\n\t<\/p>\n<\/blockquote>\n<p><\/p>\n<p>\nIt turns out that it&#39;s possible to categorize a large percentage of the kinds of date-related questions that people are likely to ask in a relatively small set of English-language constructs.&nbsp; I like to do this without regard for what the dates actually represent, and even add in some non-date concepts in a generic way.&nbsp; Once you&#39;ve done this, you can let users figure out what their questions are, by themselves, pretty flexibly.&nbsp; Here&#39;s a rough list of the types of questions we tend to see, including (in brackets) a &quot;token&quot; for each type, which I&#39;ll explain below.\n<\/p>\n<ul>\n<li><strong>[DATEOFFSET] <\/strong>A date value appears &lt;N&gt; number of days ago, or &lt;N&gt; days in the future.<\/li>\n<li><strong>[DATEBETWEEN]<\/strong> A date value appears between two date literals.<\/li>\n<li><strong>[DATEPENDING]<\/strong> A date value appears exactly on a certain date, or is pending &lt;N&gt; number of days from now. NB: The latter is really the same as [DATEOFFSET] but having two offset types allows us to set one in the past (&quot;days ago&quot;) and one in the future (&quot;days from now&quot;) without negative numbers.<\/li>\n<li><strong>[NOTYET]<\/strong> One date value has appeared &lt;N&gt; or more days ago, or earlier than a particular date literal, and a second activity date is still NULL (&quot;has not yet occurred&quot;).<\/li>\n<li><strong>[DATEGAP] <\/strong>There are &lt;N&gt; or more days between two activity dates.&nbsp; Managers love this one!&nbsp; We try to keep them from using it punitively &lt;g&gt;.<\/li>\n<li><strong>[STATUS-STILL]<\/strong> One date value has appeared &lt;N&gt; or more days ago, or earlier than a date literal, and a non-date status value has not moved forward.<\/li>\n<\/ul>\n<p>\nUsers can pick the type of question they&#39;re trying to ask<a href=\"\/lisa\/wp-non\/migrated\/WizardStep2.png\" target=\"_blank\" rel=\"noopener\"><img loading=\"lazy\" decoding=\"async\" src=\"\/lisa\/wp-non\/migrated\/preview.png\" border=\"0\" alt=\"See what I'm talking about?\" title=\"See what I'm talking about?\" width=\"12\" height=\"12\" align=\"textTop\" \/><\/a> from this generalized set, and apply it to any dates in the system<a href=\"\/lisa\/wp-non\/migrated\/WizardStep3.png\" target=\"_blank\" rel=\"noopener\"><img loading=\"lazy\" decoding=\"async\" src=\"\/lisa\/wp-non\/migrated\/preview.png\" border=\"0\" alt=\"See what I'm talking about?\" title=\"See what I'm talking about?\" width=\"12\" height=\"12\" align=\"textTop\" \/><\/a> that happen to interest them.&nbsp;&nbsp; My sproc builds the appropriate query, using the token-type to figure out the relationship between the date and offset values that have been passed.&nbsp; It adds in a large number of output columns and filters provided in later steps of this wizard (the <a href=\"http:\/\/msdn2.microsoft.com\/en-us\/library\/system.web.ui.webcontrols.wizard(VS.80)\/\" target=\"_blank\" title=\"ASP.NET 2.0 Wizard Control Class docs\" rel=\"noopener\">ASP.NET wizard control class<\/a> is really nifty for this kind of stuff).&nbsp;\n<\/p>\n<p>\nIt&#39;s not terribly elaborate, and I&#39;m sure lots of people have done something similar, but I haven&#39;t seen any interfaces that categorize date expressions in quite this way, so I thought I&#39;d mention it.\n<\/p>\n<p>\nThe report result of this generic interface, of course, is not very elaborate either.&nbsp; It&#39;s just a generic XSLT that dumps the data out for them in a couple of pre-determined target types. (If anybody is interested I will post an example of this.)\n<\/p>\n<p>\nBut users think of this interface as a kind of sketch pad.&nbsp; Since they can &quot;save their query&quot; at the end (in an XML format, naturally &lt;g&gt;), we&#39;re half-way through the requirements discussion already. Since they can edit the date and offset parameters in their recalled query on the fly when they want to &quot;re-run the report&quot;, sometimes just the generic output is fine to give them quick ad-hoc answers.&nbsp; Other times, they re-arrange the Excel output from the generic report and we use that as the &quot;sketch&quot; of the full blown custom report. Works out well for everybody.\n<\/p>\n<p>\nYeah, all right, not everybody. Not all users like to think at <strong>all<\/strong>. Can I help it if I enjoy making life more fun for those that do &lt;g&gt;?<\/p>\n","protected":false},"excerpt":{"rendered":"<p>In a recent MSDN forum question about how to Increment a Date in a Reporting Services subscription, I described how I approach the problem of a report that has been designed with one or more datetime parameters, and now has to be run on a schedule.&nbsp; Here&#39;s an excerpt from that answer, which I thought<a class=\"more-link\" href=\"https:\/\/spacefold.com\/lisa\/2007\/07\/31\/generalizing-date-related-report-parameters\/\">Read more<\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[2,5,6,10],"tags":[],"class_list":["post-196","post","type-post","status-publish","format-standard","hentry","category-asp-net","category-reporting","category-sql-server","category-xml-xslt"],"_links":{"self":[{"href":"https:\/\/spacefold.com\/lisa\/wp-json\/wp\/v2\/posts\/196","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/spacefold.com\/lisa\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/spacefold.com\/lisa\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/spacefold.com\/lisa\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/spacefold.com\/lisa\/wp-json\/wp\/v2\/comments?post=196"}],"version-history":[{"count":0,"href":"https:\/\/spacefold.com\/lisa\/wp-json\/wp\/v2\/posts\/196\/revisions"}],"wp:attachment":[{"href":"https:\/\/spacefold.com\/lisa\/wp-json\/wp\/v2\/media?parent=196"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/spacefold.com\/lisa\/wp-json\/wp\/v2\/categories?post=196"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/spacefold.com\/lisa\/wp-json\/wp\/v2\/tags?post=196"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}