E_T

导航

数据库备忘

Posted on 2015-04-22 10:57  E_T  阅读(104)  评论(0编辑  收藏  举报

返回自增ID

Select @@Identity

 

去重

distinct

时间差

DateDiff(s,'2005-07-20','2005-7-25 22:56:32')返回值为 514592 秒 
DateDiff(d,'2005-07-20','2005-7-25 22:56:32')返回值为 5 天 

返回周

select DatePart(w,'2005-7-25 22:56:32')

返回年份

select  DatePart(yyyy,'2005-7-25 22:56:32')

当前日期是几号

select DatePart(d,'2005-7-25 22:56:32')

取得当着日期在本年中的第几天

select DatePart(y,getdate())

select * from crm_contact where companyId=1 and isDelete=0 and((DatePart(y,C_birthday)-DatePart(y,getdate()))between 0 and 7)