date_col between to_date('16-10-2005','DD-MM-YYYY')
and to_date('16-10-2005','DD-MM-YYYY')
只会返回DATE
2005 年 10 月 16 日午夜的值。如果您想获取 2005 年 10 月 16 日任何时间的数据
date_col between to_date('16-10-2005','DD-MM-YYYY')
and to_date('16-10-2005 23:59:59','DD-MM-YYYY HH24:MI:SS')
会做的。也会
date_col between to_date('16-10-2005','DD-MM-YYYY')
and to_date('17-10-2005','DD-MM-YYYY') - interval '1' second
如果您未能减去那一秒,您最终还将拉date_col
取值为 2005 年 10 月 17 日午夜的行。
您还可以将trunc
功能应用于您的date_col
trunc(date_col) = date '2005-10-16'
但这会阻止使用标准索引date_col
。您通常需要在trunc(date_col)
CREATE INDEX idx_trunc_date_col
ON table_name( trunc(date_col) );