0

I got date as String in format yyyy-MM-dd and converted to dd-mmm-yyyy.

Now I need to add one day to my date.Because in my SQL when I am selecting data in between some dates like 27-aug-2017 to 29-aug-2017,it is showing values only for 27 and 28-aug-2017 and not for 29-aug-2017.So I need to add one day so I will get data for 29-aug-2017.

String dateto=request.getParameter("dateto");
                Date date1=null;
                try {
                    date1 = format1.parse(dateto);
                    temp1 = format2.format(date1);
                    System.out.println(temp1);
                } catch (ParseException e) {
                    // TODO Auto-generated catch block
                    e.printStackTrace();
                }

My sql query

PreparedStatement psmt1=conn.prepareStatement("select * from deposit2_groupc_tja05 where Account_id =? and Transaction_Date between ? and ? order by Transaction_Date");
Sagar Gangwal
  • 7,544
  • 3
  • 24
  • 38
  • https://stackoverflow.com/questions/428918/how-can-i-increment-a-date-by-one-day-in-java – Akhil S Kamath Aug 29 '17 at 09:41
  • Modify your prepared statement query to look like as (select * from deposit2_groupc_tja05 where Account_id =? and Transaction_Date between start_date and DATE_ADD(end_date, INTERVAL 1 DAY) order by Transaction_Date ) – Raju Sharma Aug 29 '17 at 09:43
  • Your question is not clear. Where do you want to make change ? Query or in Java. If you want to update java date. What Date are you using sql.Date or util.Date ? – mr.dev.null Aug 29 '17 at 10:07
  • Change can be either in query or in java.I am using util.Date – Pravin P Aug 29 '17 at 10:43

0 Answers0