Azure Synapse Analytics, How Use Dynamic Date Function

Kakehi Shunya (筧 隼弥) 201 Reputation points
2022-06-14T06:30:01.26+00:00

I'm looking to copy data from S3 to Azure data lake.
Every day the data provider creates a folder that has date of the 5-days-ago in S3.

For instance: sample_data/2022/06/14/Files
Jun 14th, the provider creates the folder of 2022/06/09

Everyday, I have to upload those files automatically using pipeline, but I don't know how use datetime function in Pipeline.

I'm looking to find a way to dynamically write the 2021_08_15 part. I can't figure it out with Microsoft expression language.

211153-%E3%82%B3%E3%83%A1%E3%83%B3%E3%83%88-2022-06-14-152738.png

I am Japanese so I am sorry for the poor English :(
Any help would be greatly appreciated.

Azure Synapse Analytics
Azure Synapse Analytics
An Azure analytics service that brings together data integration, enterprise data warehousing, and big data analytics. Previously known as Azure SQL Data Warehouse.
5,135 questions
Azure Data Factory
Azure Data Factory
An Azure service for ingesting, preparing, and transforming data at scale.
11,125 questions
0 comments No comments
{count} votes

Accepted answer
  1. Subashri Vasudevan 11,206 Reputation points
    2022-06-15T09:25:20.987+00:00

    Hey

    I got it.

    You have to place @markus.bohland@hotmail.de before the bucket name.

    Like @markus.bohland@hotmail.de ('bucketname/',formatDateTime(addDays(utcNow(),-5),'yyyy'),'/',formatDateTime(addDays(utcNow(),-5),'MM'),'/',formatDateTime(addDays(utcNow(),-5),'dd'))

    Note a slash(/) next to bucket name.
    Please try and revert.

    Thank you.


1 additional answer

Sort by: Most helpful
  1. Subashri Vasudevan 11,206 Reputation points
    2022-06-14T13:55:08.717+00:00

    Hi,

    Thanks for the ask and using MS Q&A portal.

    Under the source settings of copy activity, use the below expression, this will make sure to pick up folder with a date that is 5 days ago. Inside the folder whatever file has .txt extension, it will copy all of them to my sink (in my case it was a different container and folder)

    @formatDateTime(addDays(utcNow(),-5),'MM-dd-yyyy')

    Reference Screenshot with copy settings that worked for me:

    211349-screenshot-2022-06-14-at-71800-pm.png

    Please revert in case you are having questions.

    Thank you.


Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.