How to get 24 hours time in format yyyy-m format-dd hh:mm:ss

Tony Johansson 40 Reputation points
2023-04-21T13:49:34.76+00:00
Hello,
When a file is dropped in a container the ADF is run.
I have this expression below that is assigned to the filename that was dropped.The problem is when a file is dropped at time 15:13:10 is was recorded at 03:13:10 by the expression. I want to use 24 hours if it possible. In this case I can't see if the pipeline().TriggerTime was in the middle of the night or in the middle of the day. I use pipeline().TriggerTime because I use it in two different places because I must be sure to have the exact same time. If I were to use utcnow I would probable have different time.

Here is the expression that I use:
@concat(replace(item().name,'.xml',''),' ',formatDateTime(addHours(pipeline().TriggerTime,2),'yyyy-MM-dd hh:mm:ss'),'.json')

Many thanks in advance
Azure Data Factory
Azure Data Factory
An Azure service for ingesting, preparing, and transforming data at scale.
11,014 questions
0 comments No comments
{count} votes

1 answer

Sort by: Most helpful
  1. Subashri Vasudevan 11,206 Reputation points
    2023-04-22T12:05:20.3+00:00

    Hi @Tony Johansson Here is the expression that captures trigger time and converts to IST 24 hour format. Similar way, try to use as per your time zone. (replace expressions replace all the : and " " to _)

    @replace(replace(formatDateTime(convertFromUtc(pipeline().TriggerTime,'India Standard Time'),'yyyy-MM-dd HH:mm:ss:ffffff'),' ','_'),':','_')
    

    Output: (assigned this expression to a variable - triggertime)

    {
        "name": "triggertime",
        "value": "2023-04-22_17_56_09_216040"
    }
    
    

    In your case, are you using the expression inside a foreach loop and copy activity? I see item().name being used, so wondering your use case. Please let us know if you need any further help here. Thanks, Suba


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.