I have a column that should contains the difference between created_at and updated_at in minutes, so I tried to do the following but it usually saves the time_diff with zero. So, how can I fix that?
Product.update(
id,
time_diff: "((EXTRACT (DAY FROM (now()-created_at))*24*60*60+
EXTRACT (HOUR FROM (now()-created_at))*60*60+
EXTRACT (MINUTE FROM (now()-created_at))*60+
EXTRACT (SECOND FROM (now()-created_at)))/60)::int"
)
Aucun commentaire:
Enregistrer un commentaire