Search code examples
azure-application-insightsms-app-analytics

Extract time portion out of Timestamp


I am using Azure Application insights and would like to extract just the time portion out of Timestamp.

For ex:

   Input : "2017-01-23T20:00:00.2804261Z"; //This is a Timestamp data type
   Output : 20:00:00.2804261Z

Solution

  • You can subtract day from the existing timestamp to leave only the "time" part of it:

    QueryHere
    | extend date_output = floor(timestamp, 1d)
    | extend time_output = timestamp - date_output 
    

    The output will be something like

    Timestamp: "2017-01-23T20:00:00.2804261Z"
    date_output: "2017-01-23T00:00:00.0000000Z"
    time_output: "20:00:00.2804261"