Extract Unix timestamp from json and converting to human readable datetime

Ali, Ayesha 0 Reputation points
2025-02-28T00:29:21.3633333+00:00

Hi
I have a json file in datalake. It has createtime and updatetime fields in Unix timeformat. I am unable to transform using Derived column. I am getting null in the result.

 "createTime": 1716327033431, "updateTime": 1716327033431,

I tried various syntax
toTimestamp('createtime')

toDate('createtime')

toTimestamp(toLong(toString('createtime')),'yyyy-MM-dd HH:mm:ss')

User's image

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

1 answer

Sort by: Most helpful
  1. J N S S Kasyap 270 Reputation points Microsoft Vendor
    2025-02-28T04:38:29.97+00:00

    Hi @Ali, Ayesha

    Thank you for posting your query!

    I inferred that the createTime and updateTime values are in milliseconds based on their format in the provided JSON example
    Adjust your expression to convert the Unix timestamp from milliseconds to seconds before applying the toTimestamp() function.

    Correct Format:

    toTimestamp(toLong(createTime) / 1000, 'yyyy-MM-dd HH:mm:ss')
    

    Below Similar thread will helpful
    https://stackoverflow.com/questions/59118389/azure-data-factory-mapping-data-flow-epoch-timestamp-to-datetime

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


    If this answers your query, do click Accept Answer and Yes for was this answer helpful. And, if you have any further query do let us know.

    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.