Hi i already get the daily sales. now i want to get the weekly, monthly and yearly sales and already tried the weekly sales but the problem is the monthly sales is the one being selected
public void weekly(){
DateTimeFormatter dtf = DateTimeFormatter.ofPattern("MM/dd/yyyy");
LocalDateTime now = LocalDateTime.now();
String date = dtf.format(now);
try{
con = Connector.getConnection();
java.sql.Statement st = con.createStatement();
String query = "SELECT sum(Quantity) FROM `salesproduct_table` WHERE Date = WEEK(CURDATE())";
ResultSet rs = st.executeQuery(query);
if(rs.next()){
productsales4.setText(rs.getString(1));
}
}catch(Exception ex){
}
tried already different kind of syntax but i cant fix it
For month:
String query = "SELECT sum(Quantity) FROM `salesproduct_table` WHERE MONTH(Date) = MONTH(CURDATE())";
for year:
String query = "SELECT sum(Quantity) FROM `salesproduct_table` WHERE YEAR(Date) = YEAR(CURDATE())";
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.