数据库里面的数据格式是 date: 01-九月 -2008 12:00:00 AM(默认是'01-1月-2000' 怎么存进去就变成这样)
用rs.getString() 拿到的是 9/1/2008  00:00:00 
那我要拿一个时间和数据库里面的进行比较怎么比,如拿出01-九月 -2008 12:00:00 AM的全部数据

解决方案 »

  1.   

    用rs.getDate()取不到Date类型的数据吗?
      

  2.   

    to_date(rs.getString(),'yyyy-mm-dd')转换不行吗
      

  3.   

    取的到数据就是格式不一样了
    todata 怎么转啊 我要从数据库里面取出一个日期的数据 怎么进行数据比较啊
    还有他有个AM 
      

  4.   

    谁能帮2哦写个 sql语句 
    select * from table where date = '这边怎么写';
      

  5.   

    jsva.util.DatecompareTo方法
    public int compareTo(Date anotherDate)比较两个日期的顺序。 指定者:
    接口 Comparable<Date> 中的 compareTo
    参数:
    anotherDate - 要比较的 Date。 
    返回:
    如果参数 Date 等于此 Date,则返回值 0;如果此 Date 在 Date 参数之前,则返回小于 0 的值;如果此 Date 在 Date 参数之后,则返回大于 0 的值。 
    抛出: 
    NullPointerException - 如果 anotherDate 为 null。
    从以下版本开始: 
    1.2 
      

  6.   

    用PreparedStatementPreparedStatement pstmt = con.prepareStatement("select * from table where date = ?");pstmt.setDate(1, 你的Date对象);还有,最好用一个时间段来取时间,否则可能不是正好相等。PreparedStatement pstmt = con.prepareStatement("select * from table where date between ? and ?");pstmt.setDate(1, 靠前的时间);pstmt.setDate(1, 靠后的时间);
      

  7.   

    应该是这样PreparedStatement pstmt = con.prepareStatement("select * from table where date between ? and ?"); pstmt.setDate(1, 靠前的时间); pstmt.setDate(2, 靠后的时间); 
      

  8.   

    PreparedStatement pstmt = con.prepareStatement("select * from table where to_date(date) between ? and ?"); 用to_date定义格式后再做比较查询
      

  9.   

    数据库的存储虽然是那种格式,但是你可以根据自己的需要进行转换,例如你要查询的时期2008-09-01,
    查询串可以这么写吧
    select * from table where to_char(date,'yyyy-mm-dd') = '2008-09-01'或者
    select * from table where date = to_date('2008-09-01','yyyy-mm-dd')
    数据库里面的那个12点AM应该是说明数据库中的日期只有年月日,其他的时分秒等都是0,所以AM不用关心它。
      

  10.   

    有AM是因为你用的是12小时制的,把它格式转换为24小时的就不会出现了吧
    DATE = to_date('2008-9-9 10:50:09','yyyy-MM-dd HH:MI:SS')//或者把这里的小时“HH”换成“hh24”都可以的,不想要小时、分钟、秒,就把它省去就可以了。
      

  11.   

    问题还没解决
    我再开个贴,来者有分
    我主要要问的是 date 怎么比较啊 
    也就是上面的?是怎么写的