Abbas Hamza

Abbas Hamza

  • NA
  • 100
  • 53k

dateTime format issue when inserting into sql data table

Feb 27 2014 6:27 AM
Hi Guys,
I have wrote a stored procedure to help me in insert data into table but when i Execute the procedure from the Management Studio it throw an error about one of data type  which is @ExpiryDate  which is declared as dateTime as the error saying 
Msg 102, Level 15, State 1, Line 10
Incorrect syntax near '/'.
the sproc as follow:
 
ALTER PROCEDURE [dbo].[main_Escort_Insert]
-- Add the parameters for the stored procedure here
@EscortID int,
@FirstName varchar(50),
@Surname varchar(50),
@CrbCheck bit = 0,
@CrbRef bit = false,
@ExpiryDate dateTime = null,
@Training bit = false,
 @TrainingType bit = false
AS
BEGIN
-- SET NOCOUNT ON added to prevent extra result sets from
-- interfering with SELECT statements.
SET NOCOUNT ON;
DECLARE @Escort int
-- Insert statements for procedure here
Insert Into tb_Escorts (EscortID, FirstName,Surname, [CRB_Check], [CRB_Ref],ExpiryDate, Training, TrainingType)
VALUES(@EscortID,@FirstName,@Surname,@CrbCheck,@CrbRef,@ExpiryDate,@Training,@TrainingType)
Any advice  when i execute i enter the following for the ExpiryDate as follow
@ExpiryDate =31/01/2015, 
Msg 102, Level 15, State 1, Line 10
Incorrect syntax near '/'.
I'm using SQL 2012
any idea what format should i use to insert a date when executing the sproc from the SQL Studio Management 
thank you in advance 
 
 

Answers (4)