繁体   English   中英

添加动态内容 - Azure 数据工厂 ADF

[英]Add Dynamic Content - Azure Data Factory ADF

我需要在 ADF 中添加动态内容。 以这样的方式,它需要获得如下格式的上个月日期。

结果:2018-12.csv.zip

如果您将日期设置为 28 日,然后减去 30 天,那么您应该可以从任何日期进入上个月。 然后简单地格式化为yyyy-MM ,例如

@concat(formatDateTime(adddays(formatDateTime(utcnow(), 'yyyy-MM-28'),-30),'yyyy-MM'),'.csv.zip')

这可以通过使用https://docs.microsoft.com/en-us/azure/data-factory/control-flow-expression-language-functions来完成。

可能的解决方案:我建议您在这里使用 3 个参数。 此解决方案使用 trigger().startTime,但您也可以使用 utcnow()。

注意: adddays(trigger().startTime,-31,'MM') 将返回 12 作为月份,因为该月份是 31 天前。 如果您的触发器是在当月的 5 号或当月的第一天,那么您可以使用 -2。

processYear = @formatDateTime(adddays(trigger().startTime,-31), 'yyyy')

processMonth = @formatDateTime(adddays(trigger().startTime,-31), 'MM')

result = @concat(pipeline().parameters.processYear,'-',pipeline().parameters.processMonth,'.csv.zip').

希望这会有所帮助。

@concat(formatDateTime(subtractFromTime(utcNow(),1,'Month'), 'yyyy-MM'), '.csv.zip')

如果我知道日期但我每天都在运行我的数据工厂,那么上面给出的案例是有效的。 所以下面效果更好。

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

任何更改表示赞赏。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM