SQL date field (updating)

Results 1 to 2 of 2

Thread: SQL date field (updating)

  1. #1
    Join Date
    Dec 1969

    Default SQL date field (updating)

    Here is my SQL statement:<BR><BR>sQry="UPDATE Webcasts SET Copyright=convert(datetime, &#039;" & Request.Form("Copyright") & "&#039;), Title=&#039;" & Request.Form("Title") & "&#039;, Expiry=convert(datetime, &#039;" & Request.Form("Expiry") & "&#039;) WHERE ID=" & Request.QueryString("ID") & ""<BR><BR>Which outputs this:<BR><BR>UPDATE Webcasts SET Copyright=convert(datetime, &#039;22/02/2002&#039;), Title=&#039;Marc Title for testing&#039;, Expiry=convert(datetime, &#039;22/02/2003&#039;) WHERE ID=91<BR><BR>But I get the error:<BR><BR>Description: [Microsoft][ODBC SQL Server Driver][SQL Server]The conversion of a char data type to a datetime data type resulted in an out-of-range datetime value.<BR>Number: -2147217913 (0x80040E07)<BR>Source: Microsoft OLE DB Provider for ODBC Drivers<BR><BR>I&#039;ve looked in my database, and I see that the table shows the dates in the format dd/mm/yyyy, which is the way that I&#039;m inputting it.<BR><BR>What is the problem????<BR>

  2. #2
    Join Date
    Dec 1969

    Default RE: SQL date field (updating)

    Umm,<BR><BR>I would do a lookup on the convert function, first, I think you need to provide a date "type" for the convert. <BR><BR>if that doesn&#039;t work, cast the date first<BR>Cast(&#039;22/02/2002&#039; as datetime).<BR><BR>hth<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