Skip to content

Instantly share code, notes, and snippets.

@stevevance
Created October 9, 2022 00:13
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save stevevance/89a9210bd538e9858fe26c5644de62c6 to your computer and use it in GitHub Desktop.
Save stevevance/89a9210bd538e9858fe26c5644de62c6 to your computer and use it in GitHub Desktop.
handle invalid dates in Illinois Secretary of State incorporation data
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