如何在Azure数据工厂中使用文件创建日期[YYYYMMDDHHMMSS]参数化年月日[YYYYMMDD]。

huangapple go评论47阅读模式
英文:

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

问题

以下是翻译好的部分:

下面的 Azure Data Factory 参数将从 Azure SQLDB 中提取表名:

@pipeline().parameters.TableName

有人可以向我展示如何将上述参数添加到包括 [YYYYMMDD] 和文件创建时间 [YYYYMMDDHHMMSS]?

输出应该类似于 'mytable_20230529_20230529103096'。

我尝试添加年份如下:

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

但我得到了错误:

位置 33 'TableName' 是原始类型,不支持嵌套属性。

英文:

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

如何在Azure数据工厂中使用文件创建日期[YYYYMMDDHHMMSS]参数化年月日[YYYYMMDD]。

Any thoughts?

答案1

得分: 1

使用concat函数来连接字符串,使用formatDateTime函数来格式化日期为你需要的方式:

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

结果:

如何在Azure数据工厂中使用文件创建日期[YYYYMMDDHHMMSS]参数化年月日[YYYYMMDD]。


<details>
<summary>英文:</summary>

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

    @concat(
        pipeline().parameters.TableName,
        &#39;_&#39;,
        formatDateTime(utcNow(),&#39;yyyyMMdd&#39;),
        &#39;_&#39;,
        formatDateTime(utcNow(),&#39;yyyyMMddhhmmss&#39;)
        )
Results:

[![output][1]][1]


  [1]: https://i.stack.imgur.com/2yHfd.png

</details>



huangapple
  • 本文由 发表于 2023年5月28日 21:22:44
  • 转载请务必保留本文链接:https://go.coder-hub.com/76351721.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定