不确定如何使用NOW()
函数。似乎应该是直截了当的,但是我没有运气
SELECT DISTINCT field
FROM table
WHERE field BETWEEN '2019-01-01' and NOW()
field = varchar
答案 0 :(得分:4)
您应该匹配数据类型,以避免隐式转换:
SELECT DISTINCT field
FROM table
WHERE CAST(field AS DATE) BETWEEN DATE '2019-01-01' AND CURRENT_DATE;
SELECT DISTINCT field
FROM table
WHERE DATE(field) BETWEEN DATE '2019-01-01' AND CURRENT_DATE;