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 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…