WarBoy
WarBoy

Reputation: 176

Writing Pandas dataframe to Snowflake but issue with Date column

I've a Pandas dataframe with a date column (E.g., 29-11-2019). But when I'm writing the dataframe to Snowflake it's throwing an error like this:

sqlalchemy.exc.ProgrammingError: (snowflake.connector.errors.ProgrammingError) 100040 (22007): Date '29-11-2019' is not recognized

I've tried changing the datatype to datetime:

df['REPORTDATE'] = df['REPORTDATE'].astype('datetime64[ns]')

and I get this error:

sqlalchemy.exc.ProgrammingError: (snowflake.connector.errors.ProgrammingError) 100035 (22007): Timestamp '00:24.3' is not recognized

Will appreciate your help.

Upvotes: 1

Views: 6952

Answers (1)

MMV
MMV

Reputation: 980

Snowflake is now enforcing strict date format and the date is expected as YYYY-MM-DD . Any other format is not going to be recognized and also "odd" dates like 0000-00-00 are not going to be recognized.

You can try to change the DATE_INPUT_FORMAT in session to 'dd-MM-YYYY' and see if that fixes anything. Otherwise you'd have to re-format your source data (my guess would be strftime("%Y/%m/%d %H:%M:%S")) if there is the hour/minute/second piece in it, but be aware that in DATE format for Snowflake these are getting truncated anyway.

Upvotes: 1

Related Questions