$month_first=substr(G5_TIME_YMD, 0, 8)."1"; //이번달
$sql = "select sum(wr_1) as total from g5_write_aaa where wr_datetime >= '{$month_first}'
이번달은 이렇게 하는거 배웠습니다.
지난달은 어떻게 해야 할지요,,,(지난달 1일부터 말일까지)
|
답변 2개 / 댓글 3개
채택된 답변
+20 포인트
2018-07-09 (월) 15:23:09
Copy
select sum(wr_1) as total
from g5_write_aaa
where year(wr_datetime) = year(current_date - interval 1 month)
and month(wr_datetime) = month(current_date - interval 1 month)
답변에 대한 댓글 1개
2018-07-09 (월) 15:09:55
이렇게 하시면 됩니다.
$month_first = date("m", strtotime(G5_TIME_YMD."-1 month"));
답변에 대한 댓글 2개
2018-07-09 (월) 15:23:25
거듭 감사합니다, 알려주신대로 하니 총기간합산이 되어 버리고
$last_month = date("Y-m-d", strtotime("-1 month", time())); // 전 달
이렇게 하니 값이 약간 다른거 같습니다.
$last_month = date("Y-m-d", strtotime("-1 month", time())); // 전 달
이렇게 하니 값이 약간 다른거 같습니다.
답변을 작성하려면 로그인이 필요합니다.