请教SQL语句根据这几个条件

请教SQL语句根据这几个条件

问题描述:

开始时间 结束时间 通过地点 数据类型 车牌号码
starttime endtime area sjlx way
根据这几个条件查询的数据出来;

前台传递的时间类型是字符串类型,数据库里是date类型 这个怎么转换

查询条件是5个 where后面都要用and 连接?

JGSJ
2012/12/5 7:33:53
2012/12/5 8:36:11
2012/12/5 8:27:42
2012/12/5 8:43:28
2012/12/5 8:11:37
2012/12/5 7:07:33
2012/12/5 7:26:30
2012/12/5 8:32:22
数据库时间格式是这样的
我查询的时候 是这么写的
select * from PASS_DATA where JGSJ=to_date('2012/12/05','yyyy/mm/dd');
问题是查不出东西啊 空 语句对

1.String转化成java.sql.Date,
public static java.sql.Date convertToSqlDate(String str){
SimpleDateFormat bartDateFormat = new SimpleDateFormat("yyyy-MM-dd");
java.sql.Date sqlDate = null;
try{
java.util.Date date = bartDateFormat.parse(str);
sqlDate = new java.sql.Date(date.getTime());
System.out.println(sqlDate.getTime());
}
catch (Exception ex) {
System.out.println(ex.getMessage());
}
return sqlDate;
}

2.查询条件5个,where f1 ='' and f2 ='' and ````````````

3.至于查不出数据,是因为你条件用的是=而数据库没有时间为'2012/12/05'的数据,你换成>=吧

初学者?

你这个自己也看见了,数据库存的date是全格式的 你直接用年月日根本查不到,

2012/12/5 7:26:30肯定不等于2012/12/05了.

用between或者trunc都可以解决.