Search code examples
azure-data-factory

How to Parameterize Year Month Day [YYYYMMDD] with file created datetime [YYYYMMDDHHMMSS] in Azure Data Factory


The following Azure Data Factory parameter will pull in the tablename from an Azure SQLDB

@pipeline().parameters.TableName

Can someone show me how to add the above parameter to include [YYYYMMDD] and file created datetime [YYYYMMDDHHMMSS]

The output should look like 'mytable_20230529_20230529103096'

I tried adding the year as follows:

@pipeline().parameters.TableName.dayOfYear()

But I got the error:

Position 33 'TableName' is a primitive and doesn't support nested properties

enter image description here

Any thoughts?


Solution

  • Use concat to concatanate strings, and formatDateTime to format the date to the way you need it:

    @concat(
        pipeline().parameters.TableName,
        '_',
        formatDateTime(utcNow(),'yyyyMMdd'),
        '_',
        formatDateTime(utcNow(),'yyyyMMddhhmmss')
        )
    

    Results:

    output