Convert int to datetime in ADF

Venkatesh Srinivasan 86 Reputation points
2021-11-16T15:27:13.517+00:00

Hi @ShaikMaheer-MSFT @HimanshuSinha-msft

I would like to convert my INT datatype column to datetime.

Example :

149830-image.png

149882-image.png

I can get the date out of my column. Can you please help me how to get the timestamp along with the date.

Thanks in advance!

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

Accepted answer
  1. Michael Taylor 60,161 Reputation points
    2021-11-16T16:01:08.347+00:00

    FileNameDate is a text column, not an integer. That makes sense because an regular 32-bit int cannot hold a full date value (YY,YYM,MDD). Hence this is just a string parsing problem.

    Unfortunately your time isn't in a consistent format so there isn't going to be a "correct" way to do this. Given the following value: 12345, is this 12:34:05, 1:23:45 or something else? Unless you have the full 6 digit timestamp you are going to have to make some decisions on how to interpret the value.

    Given just your first value 21102531021 if you assume the first 6 digits are the date then this results in 10/25/2021. That leaves the remaining time of 311021 which is not a valid hhmmss value. Is this a Unix timestamp or something that represents ticks?

    1 person found this answer helpful.

0 additional answers

Sort by: Most helpful

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.