1

我尝试使用 ssis 中的以下内容将格式为 23/12/2001 的日期转换为 2001-12-23,但我一直收到错误消息。

ISNULL(Date_Of_Birth) ? NULL(DT_DBTIMESTAMP) : (DT_DBTIMESTAMP)
(SUBSTRING(Date_Of_Birth,FINDSTRING(Date_Of_Birth,"/",2) + 1,4) + "-" + RIGHT("0" + 
SUBSTRING(Date_Of_Birth,1,FINDSTRING(Date_Of_Birth,"/",1) - 1),2) + "-" + RIGHT("0" + 
SUBSTRING(Date_Of_Birth,FINDSTRING(Date_Of_Birth,"/",1) + 1,FINDSTRING(Date_Of_Birth,"/",2) - 
FINDSTRING(Date_Of_Birth,"/",1)),2))

我在 todds 博客 (http://toddmcdermid.blogspot.co.uk/2008/11/converting-strings-to-dates-in-derived.html) 上使用了那个,但由于某种原因它似乎对我不起作用。谁能解释我该怎么做

4

1 回答 1

1

也许在脚本任务中编写 .NET 代码来转换日期格式是更好的主意:

    Dim dateStr As String = "23/12/2001"
    Dim result As DateTime

    If DateTime.TryParseExact(dateStr, "dd/MM/yyyy", Nothing, Globalization.DateTimeStyles.None, result) Then
        MsgBox(result.ToString("yyyy-MM-dd"))
    End If
于 2012-07-10T02:36:46.877 回答