How can I query for records that were created at a certain hour? Will I need to add an hour column in the db for each record? Ruby will return a nice value for created_at.hour but I can’t use it in a query like as below:
results = Record.where("created_at.hour = ?", the_hour)
Try:
You need to use the MySQL
hourfunction to extract the hour from the timestamp.