How do I format date value as yyyy-mm-dd using SSIS expression builder?

前端 未结 2 1784
清歌不尽
清歌不尽 2020-12-08 20:37

hi I have taking flatfile source name dynamically I.e. filename like \"source 2011-08-11\" I\'m creating expression builder for taking most recent file as per filename. I di

相关标签:
2条回答
  • 2020-12-08 20:58

    Correct expression is

    "source " + (DT_STR,4,1252)DATEPART( "yyyy" , getdate() ) + "-" +
    RIGHT("0" + (DT_STR,4,1252)DATEPART( "mm" , getdate() ), 2) + "-" +
    RIGHT("0" + (DT_STR,4,1252)DATEPART( "dd" , getdate() ), 2) +".CSV"
    
    0 讨论(0)
  • 2020-12-08 21:03

    Looks like you created a separate question. I was answering your other question How to change flat file source using foreach loop container in an SSIS package? with the same answer. Anyway, here it is again.

    Create two string data type variables namely DirPath and FilePath. Set the value C:\backup\ to the variable DirPath. Do not set any value to the variable FilePath.

    Variables

    Select the variable FilePath and select F4 to view the properties. Set the EvaluateAsExpression property to True and set the Expression property as @[User::DirPath] + "Source" + (DT_STR, 4, 1252) DATEPART("yy" , GETDATE()) + "-" + RIGHT("0" + (DT_STR, 2, 1252) DATEPART("mm" , GETDATE()), 2) + "-" + RIGHT("0" + (DT_STR, 2, 1252) DATEPART("dd" , GETDATE()), 2)

    Expression

    0 讨论(0)
提交回复
热议问题