Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2000 Forums
 Transact-SQL (2000)
 Parameter Wrong type date issue

Author  Topic 

eewald
Starting Member

2 Posts

Posted - 2005-01-26 : 10:57:09
I'm a definite newbie with SQL.

I'm trying to construct a query in SQL Reporting Services.

I need to collect rows that lie between a certain daterange. I'd like to have the range be set with a paramter.

I think this is the relavant piece of code.

Criteria : TRANSACTIONDATE < STARTDATE + 180

This works

I try to put in a parameter

TRANSACTIONDATE < STARTDATE + @DATERANGE

and then enter in 180 when prompted but then I get this error

Application uses a value of the wrong type for the current operation

Thanks in advance!

spirit1
Cybernetic Yak Master

11752 Posts

Posted - 2005-01-26 : 11:34:49
look up DateAdd function in SQL Help = Books Online = BOL
if 180 is number of days:

dim @DATERANGE int
set @DATERANGE = 180

select *
from MyTable
where TRANSACTIONDATE < dateadd(d, @DATERANGE, STARTDATE)


Go with the flow & have fun! Else fight the flow
Go to Top of Page
   

- Advertisement -