How do you resolve errors in variable contents?

NishimuraChinatsu-9854 756 Reputation points
2023-03-29T07:22:35.4266667+00:00

Please let me know how to solve this.

I know what the cause is, but I can't think of a way to fix it.
The activity structure of synapsen is the image and JSON shown above.

The pipeline and data structure and JSON code are as shown in the URL below.
https://learn.microsoft.com/en-us/answers/questions/1193742/it-shows-2week-ago-cannot-start-with-a-numbert-and?page=1&orderby=Helpful#answers

ERROR
User's image

User's image

Contents of value of Set variable1

@concat('year=',formatDateTime(addDays(substring(variables('two_week_ago'),0,3),1),'yyyy'),'month=',formatDateTime(addDays(substring(variables('two_week_ago'),5,6),1),'mm'),'day=',formatDateTime(addDays(substring(variables('two_week_ago'),8,9),1),'dd'))

I want to achieve what is written in @concat().

Azure Synapse Analytics
Azure Synapse Analytics
An Azure analytics service that brings together data integration, enterprise data warehousing, and big data analytics. Previously known as Azure SQL Data Warehouse.
4,328 questions
{count} votes

Accepted answer
  1. AnnuKumari-MSFT 30,361 Reputation points Microsoft Employee
    2023-03-29T14:38:06.5366667+00:00

    Hi NishimuraChinatsu-9854 ,

    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:

    User's image

    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


0 additional answers

Sort by: Most helpful