首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 数据库 > Mysql >

也提一个时间有关问题,查询生日

2012-03-16 
也提一个时间问题,查询生日如果有下表staffInfo(diint,namevarchar(30),birthdatedate)现在想查处本周内

也提一个时间问题,查询生日
如果有下表
staffInfo
(di                 int,
  name             varchar(30),
  birthdate   date
);
现在想查处本周内过生日的所有员工,今天可能是本周内的任何一天.提示
select       *       from      
staffInfo
where       datediff(wk,birdthdate,getdate())=0   ;
是在SQL   server下的.

[解决办法]
select * from staffInfo where datepart=(week, birthdate)=datepart(week,getdate())
这个不行?
[解决办法]
select *
from staffInfo
where datediff(week,birthdate,getdate())+datediff(week, '1900-1-1 ',birthdate)=datediff(week, '1900-1-1 ',getdate())
[解决办法]
select * from staffInfo
where concat(year(now()), date_format(birthdate, "-%m-%d ") between curdate()- interval (dayofweek(curdate())-2) day
and curdate()+interval (8-dayofweek(curdate())) day

这个肯定行,效率吗,可能有点低
[解决办法]
select * from
staffInfo
where date_format(now(), '%u ')=date_format(birdthdate, "%u ");

热点排行