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)
 datediff

Author  Topic 

pkandoth
Starting Member

2 Posts

Posted - 2004-10-21 : 11:13:07
Hi
I've a problem!!!
i want to use datediff thats no problem. But the first parameter has to
be parameterised. What datatype do i declare it as. i declare it as varchar
it returns me an error : Invalid parameter 1 specified for datediff.

i'm doing this in a stored procedure.

Is there a way out or do i've to use the good old 'IF' or 'Case' ?


regards
pradeep

spirit1
Cybernetic Yak Master

11752 Posts

Posted - 2004-10-21 : 11:26:47
that or dynamic sql

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

spirit1
Cybernetic Yak Master

11752 Posts

Posted - 2004-10-21 : 11:31:50
you could also use this directly in select:

declare @b int
set @b = 0

select
case when @b = 0 then
datediff(d, getdate(), getdate()+7)
when @b = 1 then
datediff(hh, getdate(), getdate()+7)
when @b = 2 then
datediff(n, getdate(), getdate()+7)
end


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

- Advertisement -