2016년 7월 25일 월요일

mysql previous friday, lsat week friday, 저번주 금요일 쿼리

저번주 금요일 쿼리

select DATE_FORMAT(NOW() - INTERVAL WEEKDAY(NOW()) + 3 DAY,'%Y%m%d') CNS_DATE

월요일을 구한다음 3일을 빼주면 저번주 금요일

참고로 2주전 금요일 쿼리

SELECT WEEKDAY('20160905')
UNION ALL
SELECT DATE_ADD(DATE_FORMAT(DATE_ADD('20160905',INTERVAL - 1 WEEK) ,'%Y%m%d'),  INTERVAL - (weekday('20160905')+3) DAY)
UNION ALL
SELECT DATE_ADD(DATE_FORMAT(DATE_ADD('20160906',INTERVAL - 1 WEEK) ,'%Y%m%d'),  INTERVAL - (weekday('20160906')+3) DAY)
UNION ALL
SELECT DATE_ADD(DATE_FORMAT(DATE_ADD('20160907',INTERVAL - 1 WEEK) ,'%Y%m%d'),  INTERVAL - (weekday('20160907')+3) DAY)
UNION ALL
SELECT DATE_ADD(DATE_FORMAT(DATE_ADD('20160908',INTERVAL - 1 WEEK) ,'%Y%m%d'),  INTERVAL - (weekday('20160908')+3) DAY)
UNION ALL
SELECT DATE_ADD(DATE_FORMAT(DATE_ADD('20160909',INTERVAL - 1 WEEK) ,'%Y%m%d'),  INTERVAL - (weekday('20160909')+3) DAY)
;
=====================================================
결과
=====================================================
0
2016-08-26
2016-08-26
2016-08-26
2016-08-26
2016-08-26

댓글 없음:

댓글 쓰기

3gb minning

비트코인 골드 -- 마이너 다운로드 :  https://www.bminercontent.com/releases/bminer-v6.0.0-d111154-amd64.zip -- vcruntime140.dll 다운로드  https://www.micr...