I need to calculate DATEDIFF in minutes between 2 columns of timestamp type. There are so many simple examples on the web, but none of them
PostgreSQL does not have a datediff function. To get the number of minutes, use the SQL expression:
trunc((extract(epoch FROM newer_date) - extract(epoch FROM older_date)) / 60)
/ 60
converts to seconds to minutestrunc(…)
removes the fractional part.So probably try
sa.func.trunc((
sa.extract('epoch', datetime.utcnow()) -
sa.extract('epoch', datetime.utcnow())
) / 60)