locked
FTP TASK( getting files based on Date ) RRS feed

  • Question

  • I am working on FTP TASK. I want to download files from FTP and the file names are like mico_20141101_MI.txt(datewise). Currently i am using the Expression to get date is  

    (DT_WSTR, 4) DATEPART( "yyyy", DATEADD( "dd" , -1, GETDATE() ) ) + Right("0"+(DT_WSTR, 2)DATEPART( "mm", DATEADD( "dd" , -1, GETDATE() ) ),2) + Right("0"+(DT_WSTR, 2)DATEPART( "dd", DATEADD( "dd" , -1, GETDATE() ) ) ,2) +"_*.TXT"

    its working fine and i can download yesterday file from ftp.

    But If i want to download any particular date then how can i set variable?

    If i won't specific date and download yesterday file then above expression will be work.

    how can i use both script in Expression? pls can anyone help to me.

    Raj.

    Thursday, November 13, 2014 10:07 AM

Answers

  • But If i want to download any particular date then how can i set variable?

    In that case you need to configure this variable expression into package configurations. That means if you alter the expression via package configuration, it should evaluate to date of choice and downloads the specifc date's file.


    Thanks, hsbal

    Thursday, November 13, 2014 5:03 PM
  • I would simply assign value to a variable inside package and use the value in the expression. You can also add variable to configuration if you want to pass a value from outside. You can also add another variable to determine whether you need yesterday or specific date and set expression accordingly so that you expression will look like

    (DT_WSTR,30)([User::DateCategory] == "Specific Date"? @[User::Date]:(DT_WSTR, 4) DATEPART( "yyyy", DATEADD( "dd" , -1, GETDATE() ) ) + Right("0"+(DT_WSTR, 2)DATEPART( "mm", DATEADD( "dd" , -1, GETDATE() ) ),2) + Right("0"+(DT_WSTR, 2)DATEPART( "dd", DATEADD( "dd" , -1, GETDATE() ) ) ,2)) +"_*.TXT"

    DateCategory variable should be of type string

    and Date should of type date


    Please Mark This As Answer if it solved your issue
    Please Mark This As Helpful if it helps to solve your issue
    Visakh
    ----------------------------
    My MSDN Page
    My Personal Blog
    My Facebook Page

    Thursday, November 13, 2014 5:46 PM

All replies

  • Your expression just becomes more flexible  DATEADD( "dd" , -1, GETDATE() ) part needs to be variable driven, specifically the -1 replaced to a variable. For yesterday's you'd assign the -1 and for older files the corresponding offset.


    Arthur

    MyBlog


    Twitter

    Thursday, November 13, 2014 3:05 PM
  • But If i want to download any particular date then how can i set variable?

    In that case you need to configure this variable expression into package configurations. That means if you alter the expression via package configuration, it should evaluate to date of choice and downloads the specifc date's file.


    Thanks, hsbal

    Thursday, November 13, 2014 5:03 PM
  • I would simply assign value to a variable inside package and use the value in the expression. You can also add variable to configuration if you want to pass a value from outside. You can also add another variable to determine whether you need yesterday or specific date and set expression accordingly so that you expression will look like

    (DT_WSTR,30)([User::DateCategory] == "Specific Date"? @[User::Date]:(DT_WSTR, 4) DATEPART( "yyyy", DATEADD( "dd" , -1, GETDATE() ) ) + Right("0"+(DT_WSTR, 2)DATEPART( "mm", DATEADD( "dd" , -1, GETDATE() ) ),2) + Right("0"+(DT_WSTR, 2)DATEPART( "dd", DATEADD( "dd" , -1, GETDATE() ) ) ,2)) +"_*.TXT"

    DateCategory variable should be of type string

    and Date should of type date


    Please Mark This As Answer if it solved your issue
    Please Mark This As Helpful if it helps to solve your issue
    Visakh
    ----------------------------
    My MSDN Page
    My Personal Blog
    My Facebook Page

    Thursday, November 13, 2014 5:46 PM