笔记

来源:互联网 发布:淘宝开眼镜店 编辑:程序博客网 时间:2024/06/11 21:47

 

当天

 

select   distinct(  a. Agent_code ) as  Agent_code, b. Agent_fullname   from   welldata_result a inner join  welldata_agent b on a.agent_code=b.agent_code

where TIMESTAMPDIFF(day,  Risk_time,now())=2

(2010-06-30  ,2010-07-02)

 

上一个星期

 

select * from ht_invoice_information where create_date>=date_add(now(),interval -(8 + weekday(now())) day)

and create_date<=date_add(now(),interval -(1 + weekday(now())) day);

 

#或者

 

select * from `ht_invoice_information` where WEEKOFYEAR(create_date)=WEEKOFYEAR(DATE_SUB(now(),INTERVAL 1 week));

 

 

上月

 

select Risk_time from welldata_result  where PERIOD_DIFF(date_format(now(),'%Y%m'),date_format(Risk_time,'%Y%m')) = 1