Home All Groups Group Topic Archive Search About

Pass datetime as parameter to SP

Author
13 May 2005 10:36 AM
Agnes
my SP like this
CREATE PROCEDURE dbo.sel_apinv_nonsettle
@cocode varchar(10),
@billcode varchar(10),
@issuedate datetime,
@branchid varchar(10),
@accttype varchar(10)

IN SQL Analyzer,
exec sel_apinv_nonsettle 'CNC','CNC',getdate,'HLSHK','APINV'

and i got this error "Server: Msg 8114, Level 16, State 4, Procedure
sel_apinv_nonsettle, Line 0
Error converting data type nvarchar to datetime."

What's wrong ??

Author
13 May 2005 10:50 AM
Chandra
Hi

Probably you need to put it this way
IN SQL Analyzer,
exec sel_apinv_nonsettle 'CNC','CNC',getdate(),'HLSHK','APINV'

getdate() is a function

--
best Regards,
Chandra
http://chanduas.blogspot.com/
http://www.developersdex.com/gurus/default.asp?p=4223
---------------------------------------



Show quote
"Agnes" wrote:

> my SP like this
> CREATE PROCEDURE dbo.sel_apinv_nonsettle
> @cocode varchar(10),
> @billcode varchar(10),
> @issuedate datetime,
> @branchid varchar(10),
> @accttype varchar(10)
>
> IN SQL Analyzer,
> exec sel_apinv_nonsettle 'CNC','CNC',getdate,'HLSHK','APINV'
>
> and i got this error "Server: Msg 8114, Level 16, State 4, Procedure
> sel_apinv_nonsettle, Line 0
> Error converting data type nvarchar to datetime."
>
> What's wrong ??
>
>
>
Author
13 May 2005 11:58 AM
CBretana
Stored Proc Parameters can only be constants, or T-SQL Variables... You cnnot
directly pass an expression, or a function, to a stored proc... And even if
you could, the function getdate would require the open closed parenethses at
the end -- getdate()...

What you need to do is create a T-SQL Variable, set it to be equal to
getdate(), and then pass that variable.
Declare @GDT DateTime
Set @GDT = getdate() -- ("Current_TimeStamp" is ANSI-SQL Standard)
exec sel_apinv_nonsettle 'CNC','CNC',@GDT,'HLSHK','APINV'


exec sel_apinv_nonsettle 'CNC','CNC',getdate,'HLSHK','APINV'



Show quote
"Agnes" wrote:

> my SP like this
> CREATE PROCEDURE dbo.sel_apinv_nonsettle
> @cocode varchar(10),
> @billcode varchar(10),
> @issuedate datetime,
> @branchid varchar(10),
> @accttype varchar(10)
>
> IN SQL Analyzer,
> exec sel_apinv_nonsettle 'CNC','CNC',getdate,'HLSHK','APINV'
>
> and i got this error "Server: Msg 8114, Level 16, State 4, Procedure
> sel_apinv_nonsettle, Line 0
> Error converting data type nvarchar to datetime."
>
> What's wrong ??
>
>
>

AddThis Social Bookmark Button