I have two datetime
columns in a User
/users
table: created_at
and birthdate
. I'd like to find users whose birthdate is less than 13 years before their creation date.
The equivalent Rails if
statement would be ((created_at - birthdate) < 13.years)
How do I translate this to an ActiveRecord query (one that'll work on PostgreSQL)? Is this even possible, or will I have to iterate over all records manually?
See Question&Answers more detail:os