我想获取日期和时间大于给定日期的行。这是我的桌子:
EvDate EvTime ClBdg Name Event
18.01.2015 10:55:01 001 Jane enter
18.01.2015 19:31:21 003 Brad exit
19.01.2015 13:31:21 002 Lucy exit
给定date
的是18.01.2015
,time
是17:00:00
。期望值为:
EvDate EvTime ClBdg Name Event
18.01.2015 19:31:21 003 Brad exit
19.01.2015 13:31:21 002 Lucy exit
任何人都可以帮助我吗?
编辑:为了更清楚,我编辑了我的帖子。这是执行查询的java代码:
private static final SimpleDateFormat sdfTime=new SimpleDateFormat("HH:mm:ss");
private static final SimpleDateFormat sdfDate=new SimpleDateFormat("dd.MM.yyyy");
private long givenTimeStamp = 1421600400L;
public static Date givenDate = new Date(givenTimeStamp);
Class.forName("net.ucanaccess.jdbc.UcanaccessDriver");
String DATABASE = "jdbc:ucanaccess://"+CONF.getString("db.location")+";jackcessOpener=uz.lexus.access.crypto.MyCryptoProvider";
connection= DriverManager.getConnection(DATABASE, null, null);
List<Event> events=new ArrayList<Event>();
String selectEvents = "select EvDate,EvTime,ClBdg,Event from Evntlog_tbl where Event in ('enter','exit') and not ClBdg=0 and EvDate >= ? and EvTime > ? order by EvDate desc, EvTime desc";
PreparedStatement prstm= connection.prepareStatement(selectEvent);
java.sql.Date date=new java.sql.Date(sdfDate.parse(sdfDate.format()).getTime(givenDate));
java.sql.Time time=new Time(sdfTime.parse(sdfTime.format(givenDate)).getTime());
prstm.setDate(1,date);
prstm.setTime(2,time);
ResultSet rs = prstm.executeQuery();
现在的问题是:selectEvent 中的查询是否正确?