简体   繁体   中英

how to search for table with field datatype datetime

I have model with the name job i want to search datetime field.

my method is here :

  def self.search(search)
    if search
        where('reference_no ILIKE? OR status ILIKE? OR summary ILIKE? OR due_date LIKE?', "%#{search}%","%#{search}%","%#{search}%","%#{search}%" )
    else
       scoped
    end
  end

please tell me how to search due_date column its data type is datetime

If i am getting your question perfectly then you are searching for the field having datatype "datetime"

For that you have make it like this

Job.columns_hash["field_name"].type.to_s

It will return with field type "datetime" in string format

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM