Please start any new threads on our new
site at https://forums.sqlteam.com. We've got lots of great SQL Server
experts to answer whatever question you can come up with.
Author |
Topic |
Dazza1883
Starting Member
5 Posts |
Posted - 2009-06-12 : 04:31:57
|
I am trying to insert some dates from a csv text file along with the date of the monday from the week before. I have wrote a script which seems to 99% work but the date value on insertion always defaults to 01/01/1900 and not the date cvalue that should be inserted any help would be greatly appreciated, thanks---------------------------Dim objADORSDim objADOCnnSet objADOCnn = CreateObject("ADODB.Connection")objADOCnn.Open "CONNECTION DETAILS"Dim CurrentDateDim CurrentDayDim DateValCurrentDate = DateCurrentDay = WeekDay(CurrentDate)If CurrentDay = 2 Then DateVal = Date -7If CurrentDay = 3 Then DateVal = Date -8If CurrentDay = 4 Then DateVal = Date -9If CurrentDay = 5 Then DateVal = Date -10If CurrentDay = 6 Then DateVal = Date -11If CurrentDay = 7 Then DateVal = Date -12If CurrentDay = 1 Then DateVal = Date -13Set objFSO = CreateObject("Scripting.FileSystemObject")Set objFile = objFSO.OpenTextFile("\\fshq3294w\c$\Documents and Settings\clucasi\Desktop\timenet.txt", ForReading)Const ForReading = 1Dim arrFileLines()i = 0Do Until objFile.AtEndOfStream'Redim Preserve arrFileLines(i)strLine = objFile.ReadLinearrTimenetValues = split(strLine, ",")Insert_SQL = "INSERT INTO app_per40_data (empno,period_date,department,week_hours) VALUES (" & replace(arrTimenetValues(0),"""","") & ", " & DateVal & ", '" & replace(arrTimenetValues(4),"""","") & "', " & arrTimenetValues(5) & ")" 'MsgBox Insert_SQL objADOCnn.Execute Insert_SQL, , adExecuteNoRecordsi = i + 1LoopobjFile.Close msgbox DateValMain = DTSTaskExecResult_SuccessEnd Function |
|
Dazza1883
Starting Member
5 Posts |
Posted - 2009-06-12 : 05:40:16
|
Problem solved with a single quote around the double quotesInsert_SQL = "INSERT INTO app_per40_data (empno,period_date,department,week_hours) VALUES (" & replace(arrTimenetValues(0),"""","") & ", '" & DateVal & "', '" & replace(arrTimenetValues(4),"""","") & "', " & arrTimenetValues(5) & ")" |
|
|
|
|
|
|
|