Home > Net >  How to get the day and month with two digits in ADF Data flow?
How to get the day and month with two digits in ADF Data flow?

Time:11-30

I am trying to name my tsv file as "{test}{year}{month}{day}" in ADF Data Flow. Here is the Expression: "test {year(toDate($windowStartTime))} {month(toDate($windowStartTime))}{dayOfMonth(toDate($windowStartTime))}.tsv"

When set parameter windowStartTime to "2021 01 01", then it became "test 2021 1 1.tsv".How can I convert it to "test 2021 01 01.tsv" that month(01) and day(01) both have two digits? Thanks!!!

CodePudding user response:

Wrap the year() and month() functions inside a toString() with formatter to pad with a 0. Here is an example:

toString(month(toDate('2021/01/01','yyyy/MM/dd')),'00')

CodePudding user response:

Convert your parameter/variable to ‘yyyy-MM-dd’ format and replace ‘-‘with ‘ ’.

Use concat() function to add all the string values as below.

@concat('test',' ',replace(formatDateTime(variables('starttime'),'yyyy-MM-dd'),'-',' '),'.tsv')

enter image description here

enter image description here

  • Related