Solved

SSRS  2005 does not filter dates correctly

Posted on 2011-09-13
2
317 Views
Last Modified: 2012-05-12
What is the correct syntax when you are trying to filter a range of dates? The parameter values I had sent down to @BegPostDate and @EndPostDate were '08/01/2011' and '08/31/2011' . What SSRS returned was 08/11/2011 and 08/25/2010. The same statement issued inside SQL returns only the 08/11/2011 record. How do I correct this statement inside BIDS VS2005 to do the same? I tried using format 102 and 112 and they return no records.
select pats.paprojnumber,pats.employid,rtrim(py.lastname)+', '+rtrim(frstname)+' '+rtrim(midlname) as Employee,pats.pacostcatid,convert(char(10),pahd.papd,101) as TrxDate,paextcost,@BegPostDate, convert(char(10),@BegPostDate,112)
from pa30101 pats, pa30100 pahd, upr00100 py
where  pats.patsno = pahd.patsno and convert(char(10),pahd.papd,101)>=@BegPostDate and convert(char(10),pahd.papd,101)<=@EndPostDate and pats.employid=py.employid and pats.pacostcatid in ('ENGINEER')
order by pats.paprojnumber,pats.pacostcatid,pats.employid,convert(char(10),pahd.papd,101)

Open in new window

0
Comment
Question by:rwheeler23
2 Comments
 
LVL 28

Accepted Solution

by:
sammySeltzer earned 500 total points
ID: 36530435
How about something like this?


select pats.paprojnumber,pats.employid,rtrim(py.lastname)+', '+rtrim(frstname)+' '+rtrim(midlname) as Employee,pats.pacostcatid,convert(char(10),pahd.papd,101) as TrxDate,paextcost,@BegPostDate, convert(char(10),@BegPostDate,112)
from pa30101 pats, pa30100 pahd, upr00100 py
where  pats.patsno = pahd.patsno 
and convert(Convert(Datetime,pahd.papd,101)>=Convert(Datetime,@BegPostDate, 101)) 
and (Convert(Datetime,pahd.papd,101)<=Convert(Datetime,@EndPostDate, 101)) 
and pats.employid=py.employid 
and pats.pacostcatid in ('ENGINEER')
order by pats.paprojnumber,pats.pacostcatid,pats.employid,pahd.papd

Open in new window

0
 

Author Closing Comment

by:rwheeler23
ID: 36530790
This is another reason why you should always used stored procedures. This was jsut a quickie little report someone wanted. You run the query in SQL and it returns the correct results.

After correcting a few syntax erros with your script the report works. Thanks.
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Hi, I have heard from my friends that it’s not possible to create Label Printing report using SSRS. I am amazed after hearing this words not possible in SSRS. I googled lot and found that it is possible to some of people know about the Report Bui…
A recent question popped up and the discussion heated up regarding updating a COMMENTS (TXT) field in a table using SSRS. http://www.experts-exchange.com/Microsoft/Development/MS-SQL-Server/MS-SQL_Reporting/Q_27475269.html?cid=1572#a37227028 (htt…
This Micro Tutorial demonstrates using Microsoft Excel pivot tables, how to reverse engineer competitors' marketing strategies through backlinks.
Internet Business Fax to Email Made Easy - With  eFax Corporate (http://www.enterprise.efax.com), you'll receive a dedicated online fax number, which is used the same way as a typical analog fax number. You'll receive secure faxes in your email, f…

896 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

15 Experts available now in Live!

Get 1:1 Help Now