SQL Date Problem

Results 1 to 3 of 3

Thread: SQL Date Problem

  1. #1
    Join Date
    Dec 1969

    Default SQL Date Problem

    I have the following problem. I am retreiving a datetime field from one table and am trying to insert it into another table (this also has a datetime field), but I keep getting the following error:<BR><BR>Microsoft OLE DB Provider for ODBC Drivers error &#039;80040e07&#039; <BR><BR>[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><BR>The date is in the following format:<BR><BR>24/01/03 14:15:16<BR><BR>My Code:<BR><BR>....<BR><BR>Dim sql<BR>sql = "SELECT Upd_Date FROM table;"<BR>Set objRs = objConn.Execute(sql)<BR><BR>Dim strDate<BR>strDate = objRs("Upd_Date")<BR><BR>Dim sql2<BR>sql2 = "INSERT INTO table2 (Date_Modified) VALUES (&#039;" & strDate & "&#039;);"<BR>objConn.Execute(sql)<BR><BR>....<BR> <BR>Any ideas??<BR><BR>Thanks<BR><BR>Micheal

  2. #2
    Join Date
    Dec 1969

    Default Try this

    sql2 = "INSERT INTO table2 (Date_Modified) VALUES (SELECT Upd_Date FROM table);"

  3. #3
    Join Date
    Dec 1969

    Default RE: SQL Date Problem

    strDate = Convert(char(10),objRs("Upd_Date"), 103) <BR>where 103 stands for mm/dd/yyyy<BR>http://msdn.microsoft.com/library/default.asp?url=/library/en-us/tsqlref/ts_ca-co_2f3o.asp

Posting Permissions

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