June 26, 2009 at 2:44 pm
It will an hour by the time I post this here. I know what I am doing, simply don't know where to plug things.
I have a variable called FileCreateDate as Datetime.
Now I have a script task that goes and gets filelastmodified date, which is done by following code -- ( I am posting whole code here so that no one is confused)
Dim path As String = Dts.Variables("FullSqlServerUpdatePathFileNm").Value
Dim LastFileDate As Date = Dts.Variables("LastUpdateQuizFileDate").Value
Dim fileCreateDate As Date = File.GetLastWriteTime(path).Date
Dim fileCreateDateTime As Date = File.GetLastWriteTime(path).Date
Dts.Variables("FileCreateDate").Value = fileCreateDateTime
'File.GetLastWriteTime("C:\Text.txt").Date
If LastFileDate <> fileCreateDate Then
Dts.Variables("BooleanValue").Value = 1
Else
Dts.Variables("BooleanValue").Value = 2
End If
Dts.TaskResult = ScriptResults.Success
Now I have a sql task and in the expression of the sqlstatement source I have following "UPDATE dbo.tbl_POS_SSIS_DataFile SET FileDate = " + " ' (DT_DATE) (DT_WSTR, 24) @[User::FileCreateDate] '" + " WHERE FolderName = " + "'Update'" + " AND FileName = " + "'QIZ.txt'"
I tried every combination of CAST function. By the way my fileDate column in tbl is datetime.
I know something is wrong here? Can someone help me here to get the right order
June 26, 2009 at 8:39 pm
Here's a VB.NET function that you could adapt:
Public Function GetLongDateSQLFormat(ByVal data As Date) As String
getLongDateSQLFormat = ""
getLongDateSQLFormat = Format(data, "yyyy-MM-dd HH:m:ss.fff")
End Function
What you are aiming for here is an update statement of the form
UPDATE x
SET xDate = 'YYYY-MM-DD HH ...'
The VB.NET function returns a string in the correct form, given a date as argument.
The absence of evidence is not evidence of absence.
Martin Rees
You can lead a horse to water, but a pencil must be lead.
Stan Laurel
Viewing 2 posts - 1 through 1 (of 1 total)
You must be logged in to reply to this topic. Login to reply