How do I get the current date in an ADF Data Flow Sink action filename?

Chuck Roberts 105 Reputation points
2024-09-06T12:17:32.2633333+00:00

This is in Azure Data Factory. I have a data flow which has a sink to output to a .CSV file. I'd like to make the filename have the date like this: "out_20240906.csv".

On the Sink action there is a "Filename" field where I can enter an expression.

I've done some searching and tried 5-6 different expressions and none of them work. Search results can do it in a pipeline but I have found no pages which show how to do this in a Data Flow Sink action.

This expression doesn't give me an error but I still get my old filename "out.csv".

concat('inforout-', toString(currentUTC(), 'yyyy-MM-dd'))

This expression gives me an error in the expression editor.

concat('inforout-', formatDateTime(utcNow(), 'yyyy-MM-dd'), '.csv')

The languages for the above code are not right but I could not select a language of "None".

Thank you.

Azure Data Factory
Azure Data Factory
An Azure service for ingesting, preparing, and transforming data at scale.
10,708 questions
{count} votes

1 answer

Sort by: Most helpful
  1. Amira Bedhiafi 24,636 Reputation points
    2024-09-06T13:05:45.1733333+00:00

    To achieve your goal of dynamically generating filenames with the current date in an ADF Data Flow Sink, you need to use an expression that correctly retrieves the current UTC date and formats it. Unfortunately, in ADF Data Flow expressions, utcNow() and formatDateTime() are not directly available like in pipelines. However, you can use the ADF functions within the Sink transformation.

    You can use the toString() function with the currentDate() function to format the current date.

    
    concat('out_', toString(currentDate(), 'yyyyMMdd'), '.csv')
    

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.