WHERE ABS( DAYOFMONTH('1983/10/4')-DAYOFMONTH('2006/10/5') ) < 3;

解决方案 »

  1.   

    错了,应该是WHERE ABS( DAYOFMONTH('1983/10/4')-DAYOFMONTH(D) ) < 3;
      

  2.   

    SimpleDateFormat dateFormats = new SimpleDateFormat("MM/dd");
    GregorianCalendar calendar = new GregorianCalendar();
    calendar.setTime(dateFormats.parse("10/29")); 
    calendar.add(Calendar.DAY_OF_WEEK, -3); // 前三天

    String date1 = dateFormats.format(calendar.getTime());// 前三天 calendar.setTime(dateFormats.parse("10/29")); 
    calendar.add(Calendar.DAY_OF_WEEK, 3); // 後三天
    String date2 = dateFormats.format(calendar.getTime());// 後三天
    ---------------------
    在SQL裡查詢日期區間為data1和date2
    可查前三天和後三天的資料