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)
Azure Data Factory error while parsing String date to date SQL
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
SQL Server Other
4 answers
Sort by: Most helpful
-
Greg Low 1,980 Reputation points Microsoft Regional Director
2024-02-09T04:27:47.5033333+00:00 -
Greg Low 1,980 Reputation points Microsoft Regional Director
2024-02-09T04:31:55.0566667+00:00 (Sorry, ended up in the wrong item)
-
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. -
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])