数据库备忘

返回自增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)

原文地址:https://www.cnblogs.com/Celebrator/p/4446777.html