3

sql表达式:

select * 
  from order 
 where status=0 
   and adddate(created_time, interval 1 day)>now();

蟒蛇代码:

from sqlalchemy.sql.expression import func, text
from datetime import datetime 

closed_orders = DBSession.query(Order).filter(func.dateadd(Order.create_time,         text('interval 1 day'))>datetime.now()).all() 

但它错了。如何正确地做到这一点?

谢谢

REF:在 sqlalchemy 中使用 DATEADD

4

2 回答 2

3

尝试这个:

from sqlalchemy import func
import datetime
DBSession.query(Order)\
    .filter(func.ADDDATE(Order.create_time,1)>datetime.datetime.now())
于 2015-02-16T15:32:33.970 回答
0

快速:

extract('hour', cast(t_table.open_time,TIMESTAMP)) - 5 == 12

extract('dow', cast(cast(t_table.open_time, TIMESTAMP) - 5,TIMESTAMP)) == 3
于 2018-07-26T09:03:47.703 回答