Trying to convert a string column to date. Column currently holds values, such as '20170130', and '20161130'.
When I try:
change_column :tickets, :string_date, :date
This gives me an error:
PG::DatatypeMismatch: ERROR: column "string_date" cannot be cast automatically to type date. HINT: Specify a USING expression to perform the conversion.
So, I try:
change_column :tickets, :string_date, 'date USING CAST(string_date AS date)'
Still no luck, with the following error:
PG::InvalidDatetimeFormat: ERROR: invalid input syntax for type date
Anyone know what's going on?? Thought converting from string to date would be easier...
thanks in advance