Site Sponsored By: SQLDSC - SQL Server Desired State Configuration
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.
HiI've a problem!!! i want to use datediff thats no problem. But the first parameter has tobe parameterised. What datatype do i declare it as. i declare it as varcharit 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' ?regardspradeep
spirit1
Cybernetic Yak Master
11752 Posts
Posted - 2004-10-21 : 11:26:47
that or dynamic sqlGo with the flow & have fun! Else fight the flow
spirit1
Cybernetic Yak Master
11752 Posts
Posted - 2004-10-21 : 11:31:50
you could also use this directly in select:
declare @b intset @b = 0selectcase 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