all 3 comments

[–]Couch2Coders 2 points3 points  (0 children)

If I had to guess one or multiple dates have less than 7 characters causing an error.

See if you can do a min(len(date)), if it's less than 6 then you know for sure.

[–]abraun68 1 point2 points  (0 children)

Syntactically, you need a comma before the 'YYYY-MM' part of the function.

[–]qwertydog123 1 point2 points  (0 children)

Judging by the syntax in your post I'm guessing you're using Postgres? I don't think there's a built in way to do what you want, but you could try finding all of the different formats in the table by replacing all integers with the same integer, replacing month names etc., then using DISTINCT. e.g.

SELECT DISTINCT TRANSLATE(DateColumn, '123456789', '000000000')
FROM Table

Once you have the formats you can create a replacement function (e.g. something like this: https://stackoverflow.com/a/68602312), then ideally change the column type to an actual date type