ADF: How to update DateTime field in Dynamic Content ?

Poel van der, RE (Ron) 451 Reputation points
2022-03-16T08:29:38.66+00:00

Hi

been struggling already some time with this.

In a Script activity I have this dynamic content, using some values of the previous Script activity called 'Select_HLP_CFG':
update @{activity('Select_HLP_CFG').output.resultSets[0]['rows'][0].SRC_SCM_CODE}.@{activity('Select_HLP_CFG').output.resultSets[0]['rows'][0].SRC_DSET_TECH_NM} set Process_Date = '@{variables('datumtijd')}'

The problem is updating the Process_Date with the current timestamp. The rest works fine. I have tried many things, but nothing works.
My last try was creating a variable 'datumtijd': formatDateTime(utcnow(),'yyyy-MM-dd HH:mm:ss')
But then I get as input for that Script activity this

Input
{
"scripts": [
{
"type": "Query",
"text": "update dbo.Refresh_PBI_ds set Process_Date = 'formatDateTime(utcnow(),'yyyy-MM-dd HH:mm:ss')'"

with the error:
Error code 2011, Failure type User configuration issue, Details Incorrect syntax near 'yyyy'.

So somehow it doesn't translate it to a real value.

I hope someone can help to fix this. Thnx
Ron

@Nasreen Akter

Azure Data Factory
Azure Data Factory
An Azure service for ingesting, preparing, and transforming data at scale.
11,625 questions
{count} votes

Accepted answer
  1. ShaikMaheer-MSFT 38,546 Reputation points Microsoft Employee Moderator
    2022-03-17T13:42:41.28+00:00

    Hi @Poel van der, RE (Ron) ,

    Thank you for posting query in Microsoft Q&A Platform.

    As per my understanding you are dynamically framing UPDATE SQL query but struggling with getting UTC datetime in to variable. Please correct me if I am wrong.

    When you are assigning value into variable as dynamic content then use @{} syntax.

    Please check below images for better understanding.
    184136-image.png

    Hope this helps. Please let us know if any further queries. Thank you.

    ----------------

    Please consider hitting Accept Answer button. Accepted answers helps community as well.


0 additional answers

Sort by: Most helpful

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.