How to combine Date and Integer with Python sqlalchemy?
def getBeforePoint(userId, endDate=None): today = datetime.now().date() subquery = ( db.session.query( T_user_point.user_promotion_code_id, T_user_point.acquired_at, M_promotion_code.valid_days, T_user_promotion_code.promotion_code_id ) .join(T_user_promotion_code, T_user_point.user_promotion_code_id == T_user_promotion_code.user_promotion_code_id) .join(M_promotion_code, T_user_promotion_code.promotion_code_id == M_promotion_code.promotion_code_id) .subquery() ) subquery2 = ( db.session.query( T_user_point.user_promotion_code_id, T_user_point.acquired_at, M_promotion_code.valid_days, T_user_promotion_code.promotion_code_id ) .join(T_user_promotion_code, T_user_point.user_promotion_code_id == T_user_promotion_code.user_promotion_code_id) .join(M_promotion_code, T_user_promotion_code.promotion_code_id == M_promotion_code.promotion_code_id) .first() ) # Get valid_days as an integer valid_days = db.session.query(subquery.c.valid_days).filter( subquery.c.user_promotion_code_id == […]