Oracle:
select * from table where trunc(field) = trunc(ADD_MONTHS(sysdate,-1))SQL Server:
select * from table where DATEDIFF(day, field,getdate()) = 30

解决方案 »

  1.   

    取不出来
    sqlstr="select count(*) as num from tab where trunc(inputtime) = trunc(ADD_MONTHS(sysDate,-1))";结果总是为零?
      

  2.   

    oracle:
    sql=select * from table where time-"+currentime+"<0 and "+lasttime+"-time>0;
      

  3.   

    再外面先构造好时间段容易一些。
    timeEnd=(Interger.paesrInt(timeStart)+30).toString()
    select * from tableName where currTime between timeStart and timeEnd