Data cleaning #1296
Unanswered
pinkysouji21
asked this question in
Code with Codespaces
Data cleaning
#1296
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
UPDATE your_table
SET
salary_date = TRY_CAST(salary_date AS DATE),
attendance_date = TRY_CAST(attendance_date AS DATE),
hire_date = TRY_CAST(hire_date AS DATE);
UPDATE your_table
SET salary_date = CASE
WHEN salary_date ~ '^\d{4}-\d{2}-\d{2}$' THEN salary_date::DATE
ELSE NULL
END;
UPDATE your_table
SET hire_date = NULL
WHERE hire_date = '00/00/0000' OR hire_date = 'Unknown';
ALTER TABLE your_table ADD COLUMN hire_date_clean DATE;
UPDATE your_table
SET hire_date_clean = TRY_CAST(hire_date AS DATE);
-- Any invalid strings automatically become NULL here.
Beta Was this translation helpful? Give feedback.
All reactions