sql = "select * from table1 where time >= TO_DATE('" + d1 + "','yyyy-MM-dd-hh-mi-ss') and time <= TO_DATE('" + d2 + "','yyyy-MM-dd-hh-mi-ss')";
--time字段的格式确认是yyyy-MM-dd-hh-mi-ss这种吗?
1、如果time是字符串'yyyy-MM-dd-hh-mm-ss'格式,di、d2采用字符'yyyy-MM-dd-hh-mm-ss'格式。语句可写成如下:
sql:='select * from table1 where time between d1 and d2';
2、如果time是日期型则应该是'2012-9-8 18:55:00' 或 '08-9月 -12 08.50.45' 格式,di、d2采用字符'yyyy-MM-dd-hh-mm-ss'格式。语句可写成如下:
sql:='select * from table1 where to_char(time,'||chr(39)||'yyyy-mm-dd-hh-mm-ss'||
chr(39)||') between d1 and d2';