[英]Add Dynamic Content - Azure Data Factory ADF
I need to add a Dynamic Content in an ADF.我需要在 ADF 中添加动态内容。 In such a way that it needs to get last month date as below formate.
以这样的方式,它需要获得如下格式的上个月日期。
Result: 2018-12.csv.zip结果:2018-12.csv.zip
If you set the date to the 28th and then subtract 30 days, that should get you into the previous month from any date.如果您将日期设置为 28 日,然后减去 30 天,那么您应该可以从任何日期进入上个月。 Then simply format as
yyyy-MM
, eg然后简单地格式化为
yyyy-MM
,例如
@concat(formatDateTime(adddays(formatDateTime(utcnow(), 'yyyy-MM-28'),-30),'yyyy-MM'),'.csv.zip')
This can be done by using https://docs.microsoft.com/en-us/azure/data-factory/control-flow-expression-language-functions .这可以通过使用https://docs.microsoft.com/en-us/azure/data-factory/control-flow-expression-language-functions来完成。
Possible solution: I will suggest you to use 3 parameters here.可能的解决方案:我建议您在这里使用 3 个参数。 This solution use trigger().startTime, but you can use utcnow() aswell.
此解决方案使用 trigger().startTime,但您也可以使用 utcnow()。
Note: adddays(trigger().startTime,-31,'MM') will return 12 as month, as that month was 31 days ago.注意: adddays(trigger().startTime,-31,'MM') 将返回 12 作为月份,因为该月份是 31 天前。 If your trigger is on 5th of the month, or on the first day in the month than you can use -2.
如果您的触发器是在当月的 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').
Hope that this helps.希望这会有所帮助。
@concat(formatDateTime(subtractFromTime(utcNow(),1,'Month'), 'yyyy-MM'), '.csv.zip')
Above given case works, if I know the date but I am running my Data Factory every day.如果我知道日期但我每天都在运行我的数据工厂,那么上面给出的案例是有效的。 So below works better.
所以下面效果更好。
@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.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 。压缩')
Any changes appreciated.任何更改表示赞赏。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.