查詢當前這週的資料
select name,submittime from enterprise where yearweek(date_format(submittime,'%y-%m-%d')) = yearweek(now());
查詢上週的資料
select name,submittime from enterprise where yearweek(date_format(submittime,'%y-%m-%d')) = yearweek(now())-1;
查詢當前月份的資料
select name,submittime from enterprise where date_format(submittime,'%y-%m')=date_format(now(),'%y-%m')
查詢距離當前現在6個月的資料
select name,submittime from enterprise where submittime between date_sub(now(),interval 6 month) and now();
查詢上個月的資料
select name,submittime from enterprise where date_format(submittime,'%y-%m')=date_format(date_sub(curdate(), interval 1 month),'%y-%m')
e.g.查詢上週的資料,
select visitname,create_time from g2park_vip_info where yearweek(date_format(create_time,'%y-%m-%d')) = yearweek(now())-1;
這個now()是2018-08-09,查詢的是7.29到8.4(上週)的資料
select date_add(date_format(now(),'%y-%m-%d'),interval 0-dayofweek(now()) day);-- 上週最後一天
select date_add(date_format(now(),'%y-%m-%d'),interval 0-dayofmonth(now()) day);-- 上週最後一天
sql時間查詢上週 本週 上月 本月
如何實現只顯示本月資訊 sql select from table where datediff m,date,now 0 sql 查詢本週本月 求相差天數 select datediff day,2004 01 01 getdate 1.乙個月第一天的 select dateadd mm,date...
變位詞的查詢(上)
這次我們聊乙個比較有意思的話題 變位詞的查詢,這個話題在 程式設計珠璣 現,此書很經典,偏向於演算法,大家如果能通讀的話,肯定受益匪淺!什麼是變位詞 不同的單詞,如果其組成的字母相同的話,那麼這些單詞就互為變位詞,譬如pots stop tops這三個單詞就是互為變位詞,都是由字母p o t s組成...
mysql查詢上月的資訊
先直接上sql語句然後在解釋吧!select cast cast sum c.chrgamount 1000 as decimal 18,2 as char chrgamount,concat c.firstzm,c.secondzm as thirdzm from select from tb a...