In my Rails project, I have a scores table full of timestamp rows that I need to query and find the LATEST record from each day. My production database is PostgreSQL though I develop/test locally in sqlite3.
I'm having trouble structuring the SQL query to pull just the date from the timestamp. So if this is the timestamp: 2010-12-13 23:03:40.485012+0000, then I need to just examine 2010-12-13 and ignore the time.
Scores table:
id :integer
name :string
score :integer
updated_at :timestamp
And since I have multiple rows per day for each name, I'd like to find the MAX timestamp if each day, and just look at the latest score of each day for each name.
I've tried using the DATE() function without any luck. Anyone know the best method of doing this?