char to datetime

Results 1 to 3 of 3

Thread: char to datetime

  1. #1
    Join Date
    Dec 1969

    Default char to datetime

    Hi,<BR><BR>when i run my asp page i am getting this error.. but i converted the char value to smalldatetime value..<BR><BR><BR>Microsoft OLE DB Provider for ODBC Drivers (0x80040E07)<BR>[Microsoft][ODBC SQL Server Driver][SQL Server]The conversion of char data type to smalldatetime data type resulted in an out-of-range smalldatetime value.<BR><BR>here is my code:<BR><BR>sql = "SELECT Appl_ref_num, Fee_rec_num, applrefnum, invoice_date, invoice_num FROM testtable, testonereport WHERE testtable.Appl_ref_num = testonereport.applrefnum and testTable.Fee_rec_num is null "<BR><BR>rs.Open sql, cn<BR>do until rs.eof<BR> Applnumber = trim(rs("ApplrefNum"))<BR> feerecnum = trim(rs("invoice_num"))<BR> ReceivedDate = trim(rs("invoice_date"))<BR> <BR> <BR> Set objData = CreateObject("ADODB.Connection")<BR> objData.Open cn<BR> <BR> strSQL = "UPDATE testTable SET fee_rec_num = &#039;" & feerecnum & "&#039;, fee_rec_date = convert(smalldatetime,&#039;" & ReceivedDate & "&#039;) where Appl_ref_num = &#039;" & Applnumber & "&#039; " <BR><BR> Response.Write strSQL & "<BR>"<BR> objData.Execute strSQL<BR> <BR>rs.movenext<BR>loop<BR><BR>am i doing anything wrong??<BR><BR>thanks in advance

  2. #2

    Default Im only a beginner, however

    Id try a few of the following things...<BR><BR>write your values to screen to ensure that they are correct<BR><BR>response.write strSQL & "<BR>"<BR>response.write fee_rec_date<BR>response.end<BR><BR>if its something obvious you will see it straight away...<BR><BR>i dont see the isdate or cdate function being used anywhere? It may be that your date is invalid. Either that or perhaps you have your quotations screwed within your sql statement. Writing it to screen should clarify this.<BR><BR>No doubt the boys here will have better advice, but somewhere to start nonetheless..<BR><BR>Good luck,<BR>John

  3. #3
    Join Date
    Dec 1969

    Default RE: Im only a beginner, however

    I think it&#039;s PROBABLY the "ReceivedData" variable that&#039;s wrong, not anything else. It&#039;s failing when it&#039;s trying to do the insert.<BR><BR>As LNSE said - print out those variables, and post here what you get in your SQL statement. It&#039;s probably just that you need to format your date properly before appending it into your query.<BR><BR>Craig.

Posting Permissions

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