From f1723b39a69d7bdd4f465cdced45134f498df385 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Minh=20V=C6=B0=C6=A1ng?= Date: Tue, 5 Mar 2024 22:41:39 +0700 Subject: [PATCH] update format `created_at` in sql statement --- .../java/io/hardingadonis/saledock/dao/impl/OrderDAOImpl.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/main/java/io/hardingadonis/saledock/dao/impl/OrderDAOImpl.java b/src/main/java/io/hardingadonis/saledock/dao/impl/OrderDAOImpl.java index aaa51ea..2f37acc 100644 --- a/src/main/java/io/hardingadonis/saledock/dao/impl/OrderDAOImpl.java +++ b/src/main/java/io/hardingadonis/saledock/dao/impl/OrderDAOImpl.java @@ -95,7 +95,7 @@ public String statisticBySold(Integer duration) { try { Connection conn = Singleton.dbContext.getConnection(); - PreparedStatement smt = conn.prepareStatement("SELECT COUNT(*), DATE_FORMAT(SUBSTR(`created_at`, 1, 10), 'Tháng %m năm %Y') FROM `order` WHERE `created_at` BETWEEN DATE_SUB(CURDATE(), INTERVAL ? MONTH) AND CURDATE() GROUP BY SUBSTR(`created_at`, 1, 7)"); + PreparedStatement smt = conn.prepareStatement("SELECT COUNT(*), DATE_FORMAT(SUBSTR(`created_at`, 1, 10), 'Tháng %m năm %Y') FROM `order` WHERE SUBSTR(`created_at`, 1, 10) BETWEEN DATE_SUB(CURDATE(), INTERVAL ? MONTH) AND CURDATE() GROUP BY SUBSTR(`created_at`, 1, 7)"); smt.setInt(1, duration); ResultSet rs = smt.executeQuery(); @@ -129,7 +129,7 @@ public String statisticByStatus(Integer duration) { try { Connection conn = Singleton.dbContext.getConnection(); - PreparedStatement smt = conn.prepareStatement("SELECT COUNT(*), CASE WHEN `status` = 'PENDING' THEN 'Đang xử lý' WHEN `status` = 'SHIPPING' THEN 'Đang giao hàng' WHEN `status` = 'DONE' THEN 'Đã hoàn thành' WHEN `status` = 'CANCELLED' THEN 'Đã hủy' END FROM `order` WHERE `created_at` BETWEEN DATE_SUB(CURDATE(), INTERVAL ? MONTH) AND CURDATE() GROUP BY `status`"); + PreparedStatement smt = conn.prepareStatement("SELECT COUNT(*), CASE WHEN `status` = 'PENDING' THEN 'Đang xử lý' WHEN `status` = 'SHIPPING' THEN 'Đang giao hàng' WHEN `status` = 'DONE' THEN 'Đã hoàn thành' WHEN `status` = 'CANCELLED' THEN 'Đã hủy' END FROM `order` WHERE SUBSTR(`created_at`, 1, 10) BETWEEN DATE_SUB(CURDATE(), INTERVAL ? MONTH) AND CURDATE() GROUP BY `status`"); smt.setInt(1, duration); ResultSet rs = smt.executeQuery();