2

私はこれを試しました

db_session.query(PaymentsMade).filter(func.strftime('%B', PaymentsMade.created_at) == "August").all()

しかし、このエラーが発生しています

(ProgrammingError) function strftime(unknown, timestamp without time zone) does not exist
LINE 3: WHERE strftime('%B', paymentsmade.created_at) = 'August'
          ^
HINT:  No function matches the given name and argument types. You might need to add explicit type casts.

日付を保存していますcreated_at = datetime.utcnow()

4

1 に答える 1

4

to_charPythondatetime関数ではなく、 PostgresSQL 関数を呼び出したい場合strftime:

db_session.query(PaymentsMade) \
    .filter(func.to_char(PaymentsMade.created_at, "FMMonth") == "August")
于 2013-08-16T04:11:23.603 に答える