简体   繁体   English

雪花查询以验证日期字段

[英]Snowflake query to validate the date field

I need to validate date columns it should have case statement if the the date format it should pass or any other format is should fail and if the date format is any date format it should convert to DD-MM-yyyy format.如果它应该通过的日期格式或任何其他格式应该失败并且如果日期格式是任何日期格式它应该转换为 DD-MM-yyyy 格式,我需要验证它应该有 case 语句的日期列。 Can anyone suggest me in snowflake i need to validate the code .任何人都可以在雪花中建议我我需要验证代码。

Using TRY_TO_DATE .使用TRY_TO_DATE When the string does not match the provided format NULL is returned instead.当字符串与提供的格式不匹配时,将返回NULL

SELECT col, CASE WHEN TRY_TO_DATE(col, 'DD-MM-yyy') IS NULL THEN 'matches format'
                 ELSE 'does not match format'
            END
FROM tab;

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM