-- Change PAT_BDATE from VARCHAR(50) to DATE
-- Needed conversion from LONG (old values) to DATE
ALTER TABLE PATIENT ADD TEMP_BDATE DATE AFTER PAT_NAME;

UPDATE PATIENT SET TEMP_BDATE = CASE PAT_BDATE 
WHEN NULL THEN NULL 
WHEN "" THEN NULL
WHEN "-" THEN NULL
ELSE DATE(FROM_UNIXTIME(PAT_BDATE/1000)) END;

ALTER TABLE PATIENT DROP PAT_BDATE;

ALTER TABLE PATIENT CHANGE TEMP_BDATE PAT_BDATE DATE;