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

Tony Johansson 40 Reputation points
2023-04-21T14:11:46.8+00:00

Hello, When I file is dropped the ADF is run and this expression @concat(replace(item().name,'.xml',''),' ',formatDateTime(addHours(pipeline().TriggerTime,2),'yyyy-MM-dd hh:mm:ss'),'.json') is assigned to the file that was dropped and to a column in the database.
I need to have the same timestamp added to the file. As it is now if the file is dropped at 2023-04-20 15:13:10 I get from the expression 2023-04-20 03:13:10. I need to have 24 hours format. So as it is now I can't see if the file was dropped in the middle of the night or in the middle of the day. I was pretty sure that my expression should return is 24 hours format but I was wrong. I can't use utcNow becuse I would most certain get two different timestamp appended to the filename. Many thanks in advance

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

2 answers

Sort by: Most helpful
  1. Deleted

    This answer has been deleted due to a violation of our Code of Conduct. The answer was manually reported or identified through automated detection before action was taken. Please refer to our Code of Conduct for more information.


    Comments have been turned off. Learn more

  2. KranthiPakala-MSFT 46,642 Reputation points Microsoft Employee Moderator
    2023-04-25T22:54:10.9233333+00:00

    Hi @Tony Johansson , Welcome to Microsoft Q&A forum and thanks for reaching out here. If you would like to have your timestamp in 24 hr format, then specify the format as HH and if you would like to have the timestamp as 12 hr format then use hh. In addition as @Vinodh247 , called out you can use tt to represent AM/PM. Below are some samples.
    24 hour format specifier: @formatDateTime(convertFromUtc(utcnow(), 'Pacific Standard Time'), 'yyyy/MM/dd HH:mm:ss tt') The output for the above expression will be : 2023/04/25 15:37:48 PM 12 hour format specifier: @formatDateTime(convertFromUtc(utcnow(), 'Pacific Standard Time'), 'yyyy/MM/dd hh:mm:ss tt') The output for above expression will be: 2023/04/25 03:37:48 PM Here is a sample pipeline payload which I used for testing. Feel free to use it for your testing.

    {
        "name": "pipeline13",
        "properties": {
            "activities": [
                {
                    "name": "Set variable1",
                    "type": "SetVariable",
                    "dependsOn": [],
                    "userProperties": [],
                    "typeProperties": {
                        "variableName": "varTime",
                        "value": {
                            "value": "@formatDateTime(convertFromUtc(utcnow(), 'Pacific Standard Time'), 'yyyy/MM/dd HH:mm:ss tt')",
                            "type": "Expression"
                        }
                    }
                }
            ],
            "variables": {
                "varTime": {
                    "type": "String"
                }
            },
            "annotations": []
        }
    }
    

    Hope this helps.

    0 comments No comments

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.