changing string to date field in rails mysql -
i wanna convert data type string date format. using mysql database. values stored in "mm/dd/yyyy" format. if try convert string date using .to_date
function date values "02/28/2017", throwing invalid date error. so, decided convert datatype. suppose if convert datatype using migration happens existing records? records important. should now?
rails g migration change_date_format_in_my_table class changedateformatinmytable < activerecord::migration def change_column :my_table, :my_column, :date end def down change_column :my_table, :my_column, :string end end
Comments
Post a Comment