all groups > sql server reporting services > november 2006 >
You're in the

sql server reporting services

group:

How do I set a date criteria in a query?


How do I set a date criteria in a query? XMcknight
11/8/2006 10:56:02 AM
sql server reporting services: I'm new to this, so bear with me. :) But I'm creating a CRM report using
Visual Studio and SQL 2000. I would like be able to query on specific dates
when this report is run, but I'm having trouble with the syntax I need to
use.

Here's what I have:

SELECT vSalesActivitySummary.Activity_Count,
vSalesActivitySummary.FullName, vSalesActivitySummary.Activity_Type,
vSalesActivitySummary.CreatedOn,
OpportunityClose.StateCode
FROM vSalesActivitySummary CROSS JOIN
OpportunityClose
WHERE (OpportunityClose.StateCode = 2) OR
(OpportunityClose.StateCode = 3)
ORDER BY vSalesActivitySummary.FullName, vSalesActivitySummary.Activity_Type

Now, I had access to a similar previous report that had the date selection
criteria that I'm looking for, but when I copy and paste it into my report, I
get an error:

WHERE (CreatedOn BETWEEN @Start_Date + ' 00:00:00.000' AND @End_Date + '
23:59:59.000')
**CreatedOn is t he attribute I'm also trying to use in my own query**

I'm sure the problem is also related to where I'm trying to insert the
statement, and that's probably what I need help with.

Re: How do I set a date criteria in a query? Joe
11/8/2006 11:39:41 AM
Here is a working code snippet against AdventureWorks DB. I also noted you
were trying to evalute just TIME inside a DATE column, is that what you
wanted?

select *
from production.billofmaterials
Where UnitMeasureCode='EA'
and EndDate between '1/5/2000' and '1/1/2006'


[quoted text, click to view]
AddThis Social Bookmark Button