Add interval to timestamp using Ecto Fragments
问题 I want to write the following query in a phoenix application using Ecto fragments: select * from ( select id, inserted_at + interval '1 day' * expiry as deadline from friend_referral_code ) t where localtimestamp at time zone 'UTC' > deadline The value of expiry is an integer value that represents number of days. What I've got so far is something like this: query = from frc in FriendReferralCode, where: fragment("localtimestamp at time zone 'UTC'") > fragment("? + INTERVAL '1' * ?", frc