SELECT birthday,
CAST(CAST(datepart(yy, getdate()) AS varchar(20))
+ '-' +
CAST(datepart(mm, birthday) AS varchar(20))
+ '-' +
CAST(datepart(day, birthday) AS varchar(20)) AS datetime) AS Nbirthday
FROM CRM_Customer
WHERE birthday is not NULL
AND
(
//当前时间要大于等于生日
Datediff(day,
CAST(CAST(datepart(yy, getdate()) AS varchar(20))
+ '-' +
CAST(datepart(mm, birthday) AS varchar(20))
+ '-' +
CAST(datepart(day, birthday) AS varchar(20)) AS datetime),getdate())>=0
AND
//当前时间要减去生日,要小于7天
Datediff(day,
CAST(CAST(datepart(yy, getdate()) AS varchar(20))
+ '-' +
CAST(datepart(mm, birthday) AS varchar(20))
+ '-' +
CAST(datepart(day, birthday) AS varchar(20)) AS datetime),getdate())<7
)

SQL查询一周内过生日的用户的更多相关文章

  1. sql查询一天内的where写法,sql写法

    sql查询一天内的写法: 1. where createtime BETWEEN (select date_format(now(),'%Y-%m-%d 00:00:00')) and (select ...

  2. MYSQL查询一周内的数据(最近7天的)、最近一个月、最近三个月数据

    如果你要严格要求是某一年的,那可以这样 查询一天: select * from table where to_days(column_time) = to_days(now()); select * ...

  3. MYSQL查询一周内的数据(最近7天的)

    select * from wap_content where week(created_at) = week(now) 如果你要严格要求是某一年的,那可以这样 查询一天: select * from ...

  4. MySql 查询一周内最近7天记录

    本周内:select * from wap_content where week(created_at) = week(now) 查询一天:select * from table where to_d ...

  5. MySql 查询一周内记录

    本周内:select * from wap_content where week(created_at) = week(now) 查询一天:select * from table where to_d ...

  6. sql查询指定范围内的所有月份

    ),) FROM master..spt_values WHERE type='P' AND DATEADD(MONTH,number,'2016-01-01')<='2017-01-01'

  7. SQL 查询同一天日期内的数据

    条件如下: convert(date,a.dtClock) = convert(date,b.dtClock)

  8. Mysql 查询当天、昨天、近7天、一周内、本月、上一月等的数据(函数执行日期的算术运算)

    注:where语句后中的字段last_login_time 替换成 时间字段名 即可 #查询昨天登录用户的账号 ; #查询当天登录用户的账号 ; #查询所有last_login_time值在最后1天内 ...

  9. 不得不看,只有专家才知道的17个SQL查询提速秘诀!

    不得不看,只有专家才知道的17个SQL查询提速秘诀! 原创 2018-01-23 布加迪编译 51CTO技术栈 “ 除非你遵循本文介绍的这些技巧,否则很容易编写出减慢查询速度或锁死数据库的数据库代码. ...

随机推荐

  1. 启动mysql出现了error the server quit without updating pid file (/var/lib/mysql/localhost.localdomain.pid)

    原来是我的mysql日志太多,所以去/data/log/mysql目录(这个目录是从/etc/my.cnf中的log-error确定的)下删除了 rm -rf mysql_binary_log.*的日 ...

  2. poj 1115 Lifting the Stone 计算多边形的中心

    Lifting the Stone Time Limit:1000MS     Memory Limit:32768KB     64bit IO Format:%I64d & %I64u S ...

  3. Xamarin iOS开发中的编辑、连接、运行

    Xamarin iOS开发中的编辑.连接.运行 创建好工程后,就可以单击Xamarin Studio上方的运行按钮,如图1.37所示,对HelloWorld项目进行编辑.连接以及运行了.运行效果如图1 ...

  4. BZOJ3784 : 树上的路径

    树的点分治,在分治的时候将所有点到根的距离依次放入一个数组q中. 对于一棵子树里的点,合法的路径一定是q[L]..q[R]的某个数加上自己到重心的距离. 定义五元组(v,l,m,r,w),表示当前路径 ...

  5. javascript为元素绑定事件响应函数

    javascript中为元素设置响应时间有两种方法. (1):object.onclick=functionName; 这种方法不可以传递参数. (2):object.onclick=function ...

  6. 【转】delphi程序只允许运行一个实例的三种方法:

    一.        创建互斥对象 在工程project1.dpr中创建互斥对象 Program project1 Uses Windows,Form, FrmMain in 'FrmMain.pas' ...

  7. NHibernate's inverse - what does it really mean?

    NHibernate's concept of 'inverse' in relationships is probably the most often discussed and misunder ...

  8. Solve problem 'SURF' is not a member of 'cv'

    SIFT and SURF were moved to nonfree module. You need to add #include <opencv2/nonfree/nonfree.hpp ...

  9. IIS 301 跳转

    IIS设置301重定向 IIS服务器下做301永久重定向设置方法. IIS6设置301重定向: 1.新建一个站点,对应目录如E:\wwwroot\301web.该目录下只需要1个文件,即index.h ...

  10. IOS第六天(3:scrollView 图片轮播器)

    IOS第六天(3:scrollView 图片轮播器) #import "HMViewController.h" #define kImageCount 5 @interface H ...