none
How to add the dynamic content to the file name in Azure Datafactory V2. RRS feed

  • Question

  • Hi All,

    I need to add the dynamic content to the filename, like, if i run the activity in month may that should generate filename as 'SALES_20190228.CSV.ZIP'(it has to skip 2 previous months and should fetch the last day of the previous 3rd month).

    And I tried the following code it is generating the file name like this 201802.csv.zip

    @concat(substring(string(if(equals(int(formatDateTime(utcnow(), 'MM')),01), sub(int(formatDateTime(utcnow(), 'yyyyMM')),89),sub(int(formatDateTime(utcnow(),'yyyyMM')),2))),0,4),'-',substring(string(if(equals(int(formatDateTime(utcnow(), 'MM')),01), sub(int(formatDateTime(utcnow(), 'yyyyMM')),89),sub(int(formatDateTime(utcnow(),'yyyyMM')),2))),4,2),'.csv.zip')

    Expected result should be in the following format.

    'SALES_20190228.CSV.ZIP

    Thanks in advance.

    Thursday, April 25, 2019 6:41 AM

Answers

All replies

  • Hello Jagadeesha,

    PFB the query for the same:

    @concat('SALES_',formatDateTime(adddays(formatDateTime(concat(substring(utcnow(),0,4),'-', string(add(int(substring(utcnow(),5,2)),-2)),'-01'),'yyyy-MM-dd'),-1),'yyyyMMdd'),'.CSV.ZIP')


    Thursday, April 25, 2019 2:40 PM
  • Hello Jagadeesha,

    PFB the query for the same:

    @concat('SALES_',formatDateTime(adddays(formatDateTime(concat(substring(utcnow(),0,4),'-', string(add(int(substring(utcnow(),5,2)),-2)),'-01'),'yyyy-MM-dd'),-1),'yyyyMMdd'),'.CSV.ZIP')


    Hi Nandan,

    Thanks a lot for the logic, it worked for me.

    Friday, April 26, 2019 5:55 AM