snowflake-cloud-data-platformto-date

How to convert a VARCHAR to DATE in Snowflake


I am trying to convert a VARCHAR field to a proper date in Snowflake SQL. I have tried TRY_TO_DATE and several other functions but continue to get a parsing error. The data is originating from Excel and then to a Snowflake table. I checked to see if there were any NULLS or blanks and there is not. I am wondering if its due to a single digit for month? I double checked for spaces or anything else that might throw it off. enter image description here


Solution

  • You did tag to_date, but not sure how you used it.As the above answer states, you need to add a specifier to it.

    SELECT TO_DATE('1/22/2025', 'MM/DD/YYYY') AS date_col;
    

    It returns

    enter image description here

    Note : You mentioned you checked for blank spaces etc but there is no blank space, to_date most likely would not work with blank spaces.