Discussions
Categories
Groups
Community Home
Categories
INTERNAL ENABLEMENT
POPULAR
PUBLIC CLOUD
PRIVATE CLOUD
Quick Links
MY LINKS
HELPFUL TIPS
Back to website
Home
Intelligence (Analytics)
Report Error when dataset linked to report parameter
k1pp3r
<p>Hello,</p><p> </p><p>I have been attempting to create a new report in Birt 4.2 through an SQL database, this is the first time I have attempted to use a report parameter. My query will run fine if I do not use the parameter, however the moment I link the parameter I get an error. I want the report to prompt for a date in string format so the user can select the date they want to run the report for.</p><p> </p><p>The query is:</p><p> </p><p><strong class='bbc'>select </strong><strong class='bbc'>count</strong>(*) <strong class='bbc'>as</strong> TechService</p><p><strong class='bbc'>from</strong></p><p>TABLENAME</p><p><strong class='bbc'>Where</strong></p><p>Board_Name <strong class='bbc'>=</strong> 'Service Desk' </p><p><strong class='bbc'>AND</strong></p><p><strong class='bbc'>convert</strong>(nvarchar(50), Date_Closed,126) <strong class='bbc'>LIKE</strong> '?%'</p><p><strong class='bbc'>And</strong></p><p>closed_by <strong class='bbc'>=</strong> 'Tech Name'</p><p> </p><p>If I use '2013-10-09%' instead of the '?%' and remove the parameter then it runs fine and returns the results.</p><p> </p><p>Given the convert date field I should be able to search with a string as the parameter, however I have attempted both string and date formats which both return errors.</p><p> </p><p>Any help would be great.</p><p> </p><p>Anyone have an idea why the parameter won't work correctly?</p>
Find more posts tagged with
Comments
GLO_FR
<p>Hi,</p><p> </p><p>try this in your query and it should work</p><pre class="_prettyXprint _lang-sql">select count(*) as TechServicefrom TABLENAMEWhere Board_Name = 'Service Desk'AND convert(nvarchar(50), Date_Closed,126) LIKE (? + '%')And closed_by = 'Tech Name'</pre>
bgbaird
<p>We do this with several different methods, depending on the need. I try to stay away from the back/forth type conversions when I can. Another easy method is:</p><p> </p><p>Declare
@stDate
DATE</p><p>Set
@stDate
= ?</p><p> </p><p>SELECT stuff</p><p>FROM table</p><p>WHERE date between
@stDate
and dateadd(dd,1,
@stDate)<
;/p><p> </p><p>Brian</p>
GLO_FR
<p>BTW I agree with Brian : Converting a date to string and then use a like function is certainly not the easiest and the most efficient way to write a WHERE clause.
But my previous code works so, depending on your needs, you can still use it.</p>
k1pp3r
<blockquote class="ipsBlockquote" data-author="GLO_FR" data-cid="121285" data-time="1381763775"><div><p> </p><p>Hi,</p><p> </p><p>try this in your query and it should work</p><pre class="_prettyXprint _lang-sql">select count(*) as TechServicefrom TABLENAMEWhere Board_Name = 'Service Desk'AND convert(nvarchar(50), Date_Closed,126) LIKE (? + '%')And closed_by = 'Tech Name'</pre><p>That worked.</p><p> </p><p>The date is actually in a date/time format, is there a cleaner where statement to query on just the date portion of the date/time format column?</p></div></blockquote>
GLO_FR
Hi,
If you want to create a where statement only on the date use
convert(nvarchar(10), Date_Closed,101) LIKE (? + '%')
It will convert the timestamp in date in US format (mm/dd/yyyy)
For other format look here
<a data-ipb='nomediaparse' href='
http://msdn.microsoft.com/en-us/library/ms187928.aspx'>http://msdn.microsoft.com/en-us/library/ms187928.aspx</a>
;