[英]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.