用了hibernate的HQL语句,日期格式出了问题,arrivetime在数据库中是timestamp类型。select new classes.TrainSchedule(id,num, status,cate,fromStation,toStation,leaveTime,arriveTime,late, spent, platform,trainLate) from TrainSchedule trs where trs.arriveTime BETWEEN to_timestamp('1970-01-01 01:00:00.0','YYYY-MM-DD HH24:MI:SS.MS') AND to_timestamp('1970-01-01 12:59:00.0','YYYY-MM-DD HH24:MI:SS.MS') order by trs.arriveTime日期格式无法识别

解决方案 »

  1.   


    select new classes.TrainSchedule(id,num, status,cate,fromStation,toStation,leaveTime,arriveTime,late, spent,
     platform,trainLate) from TrainSchedule trs
     where trs.arriveTime BETWEEN to_timestamp('1970-01-01 01:00','YYYY-MM-DD HH24:MI'
    and to_timestamp('1970-01-01 12:59','YYYY-MM-DD HH24:MI')
    order by trs.arriveTime
      

  2.   


    --可能少了个括号吧
    select new classes.TrainSchedule(id,num, status,cate,fromStation,toStation,leaveTime,arriveTime,late, spent,
     platform,trainLate) from TrainSchedule trs
     where trs.arriveTime BETWEEN to_timestamp('1970-01-01 01:00','YYYY-MM-DD HH24:MI')
    and to_timestamp('1970-01-01 12:59','YYYY-MM-DD HH24:MI')
    order by trs.arriveTime
      

  3.   


    SQL> create table TrainSchedule(
      2  arriveTime timestamp
      3  );表已创建。SQL> insert into TrainSchedule values(sysdate);已创建 1 行。SQL> insert into TrainSchedule values(to_timestamp('1970-01-01 12:58','YYYY-MM-DD HH24:MI'));已创建 1 行。SQL> select * from TrainSchedule where arriveTime BETWEEN to_timestamp('1970-01-01 01:00','YYYY-MM-DD HH24:MI')
      2  and to_timestamp('1970-01-01 12:59','YYYY-MM-DD HH24:MI');ARRIVETIME                                                                      
    ---------------------------------------------------------------------------     
    01-1月 -70 12.58.00.000000 下午