Thankyou for using Microsoft Q&A platform and thanks for posting your question here.
From the details of your query, It seems you are trying to concatenate the formatted datetime values in set variable activity within until block which is failing with the invalidTemplate error. Please let me know if that is not the correct understanding.
First of all, I am curious to know what are you trying to achieve , based on my understanding, it is not a feasible way to use until block here since the pipeline will keep on running until the variable 'two_weeks _ago' matches today's day. It will keep on running day and night continuously for 2 weeks if the value for today's date is hardcoded and if it's taken by utcnow(), then it will never match and will become an endless loop and untill will not exit.
Now coming to the error, formatDateTime function expects the input to be in Date or Timestamp value . You can simply use formatDateTime(variables('week_ago'),'yyyy')
, rather than having substring within. Entire query would be :
@concat('year=',formatDateTime(variables('week_ago'),'yyyy'),'month=',formatDateTime(variables('week_ago'),'mm'),'day=',formatDateTime(variables('week_ago'),'dd'))
This will overcome the error , however, it will return the output like this:
This value will never match today's date and pipeline wont end unless you cancel it manually. Please let me know if you need further assistance. Thanks