我想在两个日期之间选择数据

时间:2015-12-14 07:35:28

标签: java sql

  SELECT pr_name,
         sub_pr_name,
         SUM(op_bal)AS opb,
         SUM(Inqty)AS inqty1 
    FROM purchasereport 
   WHERE SDate 
 BETWEEN #"+df1.format(from_d)+"# 
     AND #"+df1.format(to_d)+"# 
     AND comp_name='"+cb.getSelectedItem()+"' 
GROUP BY comp_name,pr_name,sub_pr_name 

但如果起始日期仅为01或02,则会显示结果。

1 个答案:

答案 0 :(得分:0)

尝试将SDate BETWEEN #"+df1.format(from_d)+"# AND #"+df1.format(to_d)+"#放入括号中。