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
 SQL Server Development (2000)
 Datetime parameter in Stored Procedure

Author  Topic 

AskSQLTeam
Ask SQLTeam Question

0 Posts

Posted - 2005-10-17 : 07:54:37
Dan writes "SQLSERVER 2000

I'm not sure if I am missing somthing here but I am having problems with passing in values for datetime parameters. I am getting the following error:

Error converting data type nvarchar to datetime.

I have stripped the SP down to the following but I still get the same error.

CREATE PROCEDURE date_test
(
@p_test_datetime datetime
)
AS

PRINT('Hello')
GO

If I call the SP in query analyzer as follows:

DECLARE @RC int
DECLARE @p_test_datetime datetime
-- Set parameter values
EXEC @RC = [GRFL].[dbo].[date_test] GETDATE

I get the error:

Error converting data type nvarchar to datetime.

Any ideas?"

chiragkhabaria
Master Smack Fu Yak Hacker

1907 Posts

Posted - 2005-10-17 : 08:05:13
Try this..

DECLARE @RC int
DECLARE @p_test_datetime datetime
Select @p_test_datetime = GetDAte()
EXEC @RC = [GRFL].[dbo].[date_test] @p_test_datetime



Complicated things can be done by simple thinking
Go to Top of Page

madhivanan
Premature Yak Congratulator

22864 Posts

Posted - 2005-10-17 : 08:44:03
You cannt directly use GetDate() as the parameter of sp
You need to use datetime variable as suggested

Madhivanan

Failing to plan is Planning to fail
Go to Top of Page
   

- Advertisement -