High severitydata loading
Power BI Refresh Error:
COPY INTO Date/Timestamp Conversion Error
What does this error mean?
A COPY INTO command failed because a value in the source file could not be converted to the target DATE, TIME, or TIMESTAMP column type. The date/time format in the file does not match the expected format.
Common causes
- 1File contains dates in a non-ISO format (e.g. 'MM/DD/YYYY') but the target table expects ISO 8601
- 2File format's DATE_FORMAT or TIMESTAMP_FORMAT parameter not set to match the source data
- 3Mixed date formats within the same file column
- 4Timezone offset present in some values but not others
- 5Source system changed its date serialisation format after a software update
How to fix it
- 1Inspect the raw file: `SELECT $1 FROM @stage/file.csv LIMIT 10` to see the actual date format
- 2Update the file format object: `ALTER FILE FORMAT <fmt> SET DATE_FORMAT = 'MM/DD/YYYY'`
- 3Use a SELECT transformation in COPY INTO with TO_DATE() or TRY_TO_DATE() to handle conversion explicitly
- 4Set `ON_ERROR = CONTINUE` temporarily to load valid rows and identify the format of failing values
- 5If mixed formats exist, load the column as VARCHAR and convert it in a downstream transformation step