Solved

SSRS  2005 does not filter dates correctly

Posted on 2011-09-13
2
320 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
2 Comments
 
LVL 29

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

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Introduction: This article is aimed at report developers who are used to developing reports using relational databases and have gotten a first-time assignment to develop reports on OLAP cubes. It demonstrates how to build a report using SQL Ser…
Hi All, I am here to write a simple article to move SSRS (SQL Server Reporting Services) reports from one server to another. When I have faced the same issue to move reports those were developed by developer on development server and now need to …

732 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