A.Jamal Mohammad
A.Jamal Mohammad

Reputation: 1

How to convert string column to a date column in snowflake?

a varchar column is storing date value in table_a and it looks like '24-May-2021'

now i am trying to select to_date(varchar_column, 'DD/MM/YYYY') from table_a, but was throwing below error:

Can't parse '24-May-2021' as date with format 'DD/MM/YYYY'.

please help

Upvotes: 0

Views: 1168

Answers (1)

Simeon Pilgrim
Simeon Pilgrim

Reputation: 25903

looking the the date formatting table

You should use:

select to_date(varchar_column, 'DD-MON-YYYY') from table_a;

because May is not 05 which the MM format expect, and - is not that separator you have in your data.

Upvotes: 2

Related Questions