简体   繁体   中英

How to get 30 days before data from current date. How to take two date one date from session and next data (session+30) in mysql

I want to take only two date one date from current login(session) and next date (current+30) in between operator.

WHERE " " it_service_ticket . request_date BETWEEN ? AND ? "

first ?="current time" second ?="current time" +30 days

PreparedStatement pst = con.prepareStatement(sql);
pst.setDate(1, new Date(session.getCreationTime()));
pst.setDate(2, new Date(session.getCreationTime())-30);

how to possible

probably you are looking for DATE_ADD() function like

WHERE `it_service_ticket.request_date`
  BETWEEN NOW() AND DATE_ADD(NOW(), INTERVAL 30 DAY);

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM