I have an ActiveRecord model that has a date attribute. Is it possible to utilize that date attribute to find by Year, Day and Month:
Model.find_by_year(201
No need for extract method, this works like a charm in postgresql:
extract
text_value = "1997" # or text_value = '1997-05-19' or '1997-05' or '05', etc sql_string = "TO_CHAR(date_of_birth::timestamp, 'YYYY-MM-DD') ILIKE '%#{text_value.strip}%'" YourModel.where(sql_string)