Azure Data Factory error while parsing String date to date SQL

Swati Tiwari 0 Reputation points
2024-02-09T02:17:07.1866667+00:00

Hi, I am trying to copy data from a CSV to SQL server. While writing the data I am changing the schema for a column (Source Date (string) --> Target date (date)) in mapping. There is no empty value in the column. I am getting the error :

ErrorCode=SqlOperationFailed,
'Type=Microsoft.DataTransfer.Common.Shared.HybridDeliveryException,
Message=A database operation failed. Please search error to get more details.,
Source=Microsoft.DataTransfer.ClientLibrary,''Type=Microsoft.Azure.Data.Governance.Plugins.Core.TypeConversionException,
Message=Exception occurred when converting value '24/01/2024' for column name 'EXPORT_DATE' from type 'String' (precision:, scale:) to type 'DateTime' (precision:255, scale:255). 
Additional info: String was not recognized as a valid DateTime.,Source=Microsoft.DataTransfer.ClientLibrary,''Type=System.FormatException,Message=String was not recognized as a valid DateTime.,Source=mscorlib,'
Azure Data Factory
Azure Data Factory
An Azure service for ingesting, preparing, and transforming data at scale.
11,623 questions
SQL Server Other
{count} votes

4 answers

Sort by: Most helpful
  1. Greg Low 1,980 Reputation points Microsoft Regional Director
    2024-02-09T04:27:47.5033333+00:00

    The default date format for SQL Server is US date format. That date in the error (24/01/2024) is not valid for US date format. What we usually do, is to land the data directly in SQL Server as a string, and then use T-SQL code to interpret it as needed. (e.g. by using CONVERT or PARSE) If there is any chance to modify the source query, try to put the date in a region-neutral format eg: 'YYYYMMDD'. SQL Server will always interpret an 8 digit string as YYYYMMDD. (Note no dashes or slashes)

    1 person found this answer helpful.

  2. Greg Low 1,980 Reputation points Microsoft Regional Director
    2024-02-09T04:31:55.0566667+00:00

    (Sorry, ended up in the wrong item)

    0 comments No comments

  3. ShaikMaheer-MSFT 38,546 Reputation points Microsoft Employee Moderator
    2024-02-09T13:21:26.8666667+00:00

    Hi Swati Tiwari, Thank you for posting query in Microsoft Q&A Platform.

    You need to consider provided source side date format details under mappings tab. Kindly check below link to understand, how to do the same.

    https://learn.microsoft.com/en-us/answers/questions/439579/does-adf-copy-acitivity-allow-to-format-date-using Hope this helps. Please let me know how it goes.


    Please consider hitting Accept Answer button. Accepted answers help community as well. Thank you.


  4. Swati Tiwari 0 Reputation points
    2024-02-16T06:12:07.6133333+00:00

    I ended up writing data flow (used derived column: concat(split(EXPORT_DATE,'/')[3],'-',split(EXPORT_DATE,'/')[2],'-',split(EXPORT_DATE,'/')[1])


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.