Error converting data type nvarchar to datetime
-
Hi All, I have a stored procedure as below,
ALTER PROCEDURE [dbo].[usp_Update_Service_Program_Detail]
@PK_Service_Program_County_RateCap_Detail int,
@Unit_Type int,
@Rate_Cap decimal(15,2),
----@County int,
@ModifiedBy nvarchar(50),
@ModifiedOn datetime=getdate
AS
BEGINselect '220' 'Col' -- Test statement
--Logic is here
ENDBut when I am running the stored procedure as below:
exec usp_Update_Service_Program_Detail @PK_Service_Program_County_RateCap_Detail= 53196434
, @Unit_Type=1
, @Rate_Cap=100
, @ModifiedBy='aaleemmo'
, @ModifiedOn=getdateI am getting the following error:
Error converting data type nvarchar to datetime at @ModifiedOn=getdate
Why is it an error, when getdate returns datetime why should I convert it into Datetime again, when I try it, its giving me error. Can anybody please help me what is the way to execute it and I am getting similar problem from my C# code also, can anybody please help me in this regards. Thanks in advance. Thanks, Abdul Aleem "There is already enough hatred in the world lets spread love, compassion and affection."
-
Hi All, I have a stored procedure as below,
ALTER PROCEDURE [dbo].[usp_Update_Service_Program_Detail]
@PK_Service_Program_County_RateCap_Detail int,
@Unit_Type int,
@Rate_Cap decimal(15,2),
----@County int,
@ModifiedBy nvarchar(50),
@ModifiedOn datetime=getdate
AS
BEGINselect '220' 'Col' -- Test statement
--Logic is here
ENDBut when I am running the stored procedure as below:
exec usp_Update_Service_Program_Detail @PK_Service_Program_County_RateCap_Detail= 53196434
, @Unit_Type=1
, @Rate_Cap=100
, @ModifiedBy='aaleemmo'
, @ModifiedOn=getdateI am getting the following error:
Error converting data type nvarchar to datetime at @ModifiedOn=getdate
Why is it an error, when getdate returns datetime why should I convert it into Datetime again, when I try it, its giving me error. Can anybody please help me what is the way to execute it and I am getting similar problem from my C# code also, can anybody please help me in this regards. Thanks in advance. Thanks, Abdul Aleem "There is already enough hatred in the world lets spread love, compassion and affection."
indian143 wrote:
@ModifiedOn datetime=getdate
Try GetDate**()**
Never underestimate the power of human stupidity RAH
-
Hi All, I have a stored procedure as below,
ALTER PROCEDURE [dbo].[usp_Update_Service_Program_Detail]
@PK_Service_Program_County_RateCap_Detail int,
@Unit_Type int,
@Rate_Cap decimal(15,2),
----@County int,
@ModifiedBy nvarchar(50),
@ModifiedOn datetime=getdate
AS
BEGINselect '220' 'Col' -- Test statement
--Logic is here
ENDBut when I am running the stored procedure as below:
exec usp_Update_Service_Program_Detail @PK_Service_Program_County_RateCap_Detail= 53196434
, @Unit_Type=1
, @Rate_Cap=100
, @ModifiedBy='aaleemmo'
, @ModifiedOn=getdateI am getting the following error:
Error converting data type nvarchar to datetime at @ModifiedOn=getdate
Why is it an error, when getdate returns datetime why should I convert it into Datetime again, when I try it, its giving me error. Can anybody please help me what is the way to execute it and I am getting similar problem from my C# code also, can anybody please help me in this regards. Thanks in advance. Thanks, Abdul Aleem "There is already enough hatred in the world lets spread love, compassion and affection."
Dear Abdul Aleem. i find your error and please try this code.
create PROCEDURE [dbo].[usp_Update_Service_Program_Detail]
@PK_Service_Program_County_RateCap_Detail int,
@Unit_Type int,
@Rate_Cap decimal(15,2),
----@County int,
@ModifiedBy nvarchar(50),
@ModifiedOn datetime=getdate
AS
BEGINselect '220' 'Col' -- Test statement
--Logic is here
ENDexec usp_Update_Service_Program_Detail @PK_Service_Program_County_RateCap_Detail= 53196434, @Unit_Type=1
, @Rate_Cap=100
, @ModifiedBy='aaleemmo'
, @ModifiedOn=''