Created
September 15, 2021 11:20
-
-
Save thangarajan8/c6cb2167c6729e4ec79c44d4a81f7281 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
SELECT | |
Coalesce( | |
try(date_parse(multi_date_format, '%Y-%m-%d %H:%i:%s')), | |
try(date_parse(multi_date_format, '%Y/%m/%d %H:%i:%s')), | |
try(date_parse(multi_date_format, '%Y/%m/%d')), | |
try(date_parse(multi_date_format, '%d %M %Y')), | |
try(date_parse(multi_date_format, '%d %M %Y %H:%i:%s')), | |
try(date_parse(multi_date_format, '%d/%m/%Y %H:%i:%s')), | |
try(date_parse(multi_date_format, '%d-%m-%Y %H:%i:%s')) | |
) as DateConvertedToTimestamp, | |
multi_date_format from ( | |
SELECT * | |
FROM | |
( | |
SELECT '2021-01-15 13:01:01' AS multi_date_format | |
UNION ALL | |
SELECT '2021/01/15 13:01:02' | |
UNION ALL | |
SELECT '2021/01/03' | |
UNION ALL | |
SELECT '04 JAN 2021' | |
UNION ALL | |
SELECT '05 JAN 2021 13:01:05' | |
UNION ALL | |
SELECT '06/01/2021 13:01:06' | |
UNION ALL | |
SELECT '07-01-2021 13:01:07' | |
) AS multi_date) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment