Cannot convert UTC to timestamp in Azure Data Factory

Markus Haunschmid 51 Reputation points
2022-09-27T13:16:23.553+00:00

Hi, i am not able to convert a UTC string value in a ADF cast transformation to a valid timestamp.
A Sample string value:
2022-09-27T11:45:11.2830000Z

The cast settings:

245154-image.png

Data preview shows an error and the Timestamp column is NULL.

245171-image.png

Any ideas?
Is there a type mismatch between the UTC and the timestamp format in ADF. I'm not sure, but are there 4 digits missing (only SSS instead of SSSSSSS)?
Even if i try to insert 4 additional SSSS in to the format string I receive the very same error.

Thanks a lot!

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

Accepted answer
  1. KranthiPakala-MSFT 46,642 Reputation points Microsoft Employee Moderator
    2022-09-28T01:28:42.373+00:00

    Hello @Markus Haunschmid ,

    Thanks for the question and using MS Q&A platform.

    As per my understanding your source data column has a timestamp value of type string and you would like to convert it into timestamp datatype column using Mapping data flow. When you are using Cast transformation for the format 'yyyy-MM-dd'T'hh:mm:ss.SSS'Z' you are seeing an error sign. Please correct if I'm not clear.

    The reason for the error sign is that you are using a cast transformation with Assert type check enabled. Which means the cast transformation allows for type checking. If the casting fails, the row will be marked as an assertion error that you can trap later in the stream and type conversion errors always result in NULL and require explicitly error handling using an Assert transformation.

    The issue here is your source format is 'yyyy-MM-dd'T'hh:mm:ss.SSSSSSS'Z' but in ADF the timeStamp format is support only until 3 digits of milliseconds i.e., 'yyyy-MM-dd'T'hh:mm:ss.SSS'Z' . Hence it is resulting in type conversion failure against your source data and marked as error and value is displayed as Null

    To overcome this issue, you will have to handle this explicitly. For that you can use a derived column transformation instead of Cast transformation and use the below expression to convert your input datetime value string type to a timeStamp type.

    toTimestamp(((left(TimeStampColumn, 23)) + 'Z'), 'yyyy-MM-dd\'T\'hh:mm:ss.SSS\'Z\'')  
    

    Below is a sample for converting 'yyyy-MM-dd'T'hh:mm:ss.SSSSSSS'Z' to 'yyyy-MM-dd'T'hh:mm:ss.SSS'Z' format timeStamp.

    245351-image.png

    Hope this will help.

    ------------------------------

    • Please don't forget to click on 130616-image.png or upvote 130671-image.png button whenever the information provided helps you. Original posters help the community find answers faster by identifying the correct answer. Here is how
    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.