Date problem

Results 1 to 2 of 2

Thread: Date problem

  1. #1
    DKL Guest

    Default Date problem

    Hi,<BR><BR>I have date field in my asp page. In the next page I&#039;m performing below functionality. <BR><BR>&#060;%<BR>CreationDate = request("CreationDate")<BR><BR>set RS = Server.Createobject("ADODB.Recordset")<BR>SQL = "EXEC spInsertRecord " + Num + "," + CreationDate <BR>RS.Open SQL, conn<BR><BR>%&#062;<BR><BR><BR>But I&#039;m getting <BR>Incorrect syntax near &#039;/&#039;. <BR>error if I enter 01/01/2001 in the date field. How to fix this problem? I really appreciate some help.<BR><BR><BR>My Stored procedure looks like this<BR><BR>CREATE PROCEDURE spInsertRecord<BR> @Num varchar(10),<BR> @CreationDate datetime<BR><BR>AS<BR><BR> insert into Table1 values (@Num, @CreationDate)<BR>GO<BR><BR>Thanks<BR>

  2. #2
    Join Date
    Dec 1969

    Default Put '...' around date...

    SQL Server (and all DBs except Access) use &#039;...&#039; around dates, same as around strings.<BR><BR>And *PLEASE* use & to concatenate strings! If you use + you will sometimes NOT get what you expect!<BR><BR><BR>SQL = "EXEC spInsertRecord " & Num & ",&#039;" & CreationDate & "&#039;"<BR><BR>

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts