Search code examples
ruby-on-rails-3postgresqlhstore

How to typecast string to date object In hstore


typecast string object to date in hstore

I have done typecast for string like this Project.where("(form_data -> '12')::int > 2") it is working fine but unable to typecast it for date like Project.where("(form_data -> '12-13-10-2016')::date > 22-102016").

it give me error ActiveRecord::StatementInvalid: PG::Error: ERROR: schema "date" does not exist


Solution

  • I got the answer for the question I asked here is the solutions

    Project.where("(form_data -> '22-10-2014')::date > to_date('05 Dec 2000', 'DD Mon YYYY')")

    I referred this