Reputation: 342
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?
Upvotes: 1
Views: 299
Reputation: 175716
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));
Upvotes: 1