顯然,我無法比較peewee SQL中的日期。peewee sql比較datetime Python
START_DATE = datetime.datetime(2015, 7, 20, 0, 0, 0)
customer_records = Customers.select().\
join(Current_Insurers, on=(Customers.current_insurer == Current_Insurers.id)).\
switch(Current_Insurers).\
join(Insurers, on=(Current_Insurers.insurer == Insurers.id)).\
where(Customers.pol_type == "PC" & \
Current_Insurers.effective_date == START_DATE)
凡Customers
,Current_Insurers
,Insurers
三個class
。結果始終爲0條記錄。但是,如果我刪除從SQL的datetime
條件和比較如下
customer_records = Customers.select().\
join(Current_Insurers, on=(Customers.current_insurer == Current_Insurers.id)).\
switch(Current_Insurers).\
join(Insurers, on=(Current_Insurers.insurer == Insurers.id)).\
where(Customers.pol_type == "PC"
for r in customer_records:
if(r.current_insurer.effective_date == START_DATE):
print(r.policy_id)
令人驚訝的,我們現在可以比較和打印出來的客戶。
如何在peewee
sql
中添加datetime
條件需要做些什麼?
非常感謝,