<p>我想知道两次约会在SQLAlchemy上的区别。使用Postgresql,我有以下工作:</p>
<pre><code>SELECT
EXTRACT(EPOCH FROM ('2019-02-11 17:59:05.953894'::timestamp - '2019-02-11 17:59:01.953894'::timestamp))
</code></pre>
<p>但是,我在SQLAlchemy中尝试同样的方法时遇到了问题:</p>
<pre><code>session.query(func.extract('epoch',func.date(subquery.c.dt_final.cast(Date)))-
func.date(subquery.c.dt_start.cast(Date))).all()
</code></pre>
<p>获取此错误:</p>
<pre><code>ProgrammingError: (psycopg2.errors.UndefinedFunction) operator does not exist: double precision - date
LINE 1: ...h FROM date(CAST(anon_2.dt_final AS DATE))) - date(CAS...
^
HINT: No operator matches the given name and argument types. You might need to add explicit type casts.
</code></pre>
<p>在SQLAlchemy中,如何正确地获得两个日期之间的差异</p>
<p>谢谢</p>