postgresql - 如何比较没有时间的日期?

postgresql - How to compare date without time?

我正在使用 psycopg2,问题是如何比较没有时间的日期?

cur.execute("UPDATE daily_price SET price = '"+price+"' WHERE date_time = '"+date+"';")

date_time 数据库中的值为 2000-01-01 00:00:00+08

可变日期值为 2011-11-01 00:00:00

我要找的是比较2000-01-01 = 2000-01-01没有时间

假设 date 是一个字符串(看起来像,因为您在查询中将它连接起来),您应该能够做到:

cur.execute("UPDATE daily_price SET price = '"+price+"' WHERE date_time::DATE = '"+date.split()[0]+"';")