Created
October 9, 2022 00:13
-
-
Save stevevance/89a9210bd538e9858fe26c5644de62c6 to your computer and use it in GitHub Desktop.
handle invalid dates in Illinois Secretary of State incorporation data
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
create or replace function is_date(s varchar) returns boolean as $$ | |
/* function via https://stackoverflow.com/a/25374982 */ | |
begin | |
perform s::date; | |
return true; | |
exception when others then | |
return false; | |
end; | |
$$ language plpgsql; | |
begin; | |
update ilsos_corps_llc_master | |
set date_status_date = CASE WHEN is_date(status_date) THEN status_date::date ELSE null END; | |
commit; | |
rollback; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment