I have a mix of date of births in my database. Some are of the format yyyyy-mm-dd
and some are of form mm:dd:yyyy
. I am trying to calculate age and that makes it difficult for me to do date. How can i standardize the dates?
SELECT date_of_birth
FROM ( SELECT attrs::JSON->'info'->>'date_of_birth'
FROM users ) AS date_of_birth;
date_of_birth
--------------
(2000-11-03)
(2000-06-11)
(2000-05-31)
(2008-11-26)
(2007-11-09)
(2020-03-26)
(2018-06-30)
(02:21:2020)
(2007-10-09)
There are only a couple of mm:dd:yyyy
date of births. I tried updating the field in the JSON by
UPDATE users
SET attrs::JSON->'info'->>'date_of_birth'='02-21-2020'
WHERE attrs::JSON->'info'->>'date_of_birth'='02:21:2020'
but its erroring out
ERROR: syntax error at or near "::"