Forum Discussion

Sathyajayaraman's avatar
Sathyajayaraman
Copper Contributor
Jan 17, 2024

TO pass variable value dynamically in WEB URL Data Factory

I have a pipeline where i request a TOKEN authentication followed by fetching values using the TOKEN from third party application. my WEB URL settings looks like below:

@concat('https://myapp/api/site/mysiteid/extract?startUpdateDate=',variables('start'),'&endUpdateDate=',variable('end')

 

In the above, am passing the START & END date as a pipeline variable. If i define the variable values as below - it works great.

start = 1672531200000  &   end = 1692737200000

 

Now my requirement is - i need to pass start as Yesterday's start and end as Yesterday's end. For example, if yesterday is 16th January 2024, i want the variable values to be dynamically picked as 

 

Start = 1705363200000   (16th Jan 2024 00:00:00)

End =  1705449599000   (16th Jan 2024 23:59:59)

 

Likewise every day @6am - the pipeline has to pickup the previous day TIMESTAMP values. How can i achieve this?

  • zhenguoyu's avatar
    zhenguoyu
    Copper Contributor

    Sathyajayaraman 

    Hey bro, do like this: Set variable start with 

    @div(sub(ticks(concat(formatDateTime(addDays(utcNow(),-1),'yyyy-MM-dd'), 'T00:00:00.0000000Z')), ticks('1970-01-01T00:00:00.0000000Z')), 10000)
    and set variable end with 
    @div(sub(ticks(concat(formatDateTime(addDays(utcNow(),-1),'yyyy-MM-dd'), 'T23:59:59.0000000Z')), ticks('1970-01-01T00:00:00.0000000Z')), 10000).
     
    I guess that what you want is converting the timestamp into standard ticks(The number of milliseconds passed since 1970-01-01). But the ADF built-in function ticks returns the number of nanoseconds passed since 0000-01-01, so you need do some processing after getting it.

Resources