1

I have a column with invalid date strings in snowflake and I need to cast them to date. I tried with TRY_CAST, TRY_DATE, IS_DATE but nothings seems to work, i.e.

select * from (values (1, TRY_CAST('1985-02-30' as date)));

Invalid expression [TRY_CAST('1985-02-30' AS DATE)] in VALUES clause

Is there an easy way to do a validation on the date itself?

1 Answer 1

1

The VALUES requires simple expression or constants. The alternative is SELECT:

select * from (values (1, TRY_CAST('1985-02-30' as date)));
=>
select * from (select 1, TRY_CAST('1985-02-30' as date));
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.