生日报表关于时间的处理

需求:从contact表中搜索出时间段是2010-11-12到2011-03-12的联系人
使用mysql时间函数来构造sql放到birt的query里面
sql:
select * from contact c where 
(DATE_ADD(c.birthday,INTERVAL (YEAR(NOW())-YEAR(c.birthday)) YEAR)  >= '2010-11-12 00:00:00' 
and  DATE_ADD(c.birthday,INTERVAL (YEAR(NOW())-YEAR(c.birthday)) YEAR) <= '2011-03-12 00:00:00' ) 
or  (DATE_ADD(c.birthday,INTERVAL (YEAR(NOW())-YEAR(c.birthday)+1) YEAR)  >= '2010-11-12 00:00:00' 
and  DATE_ADD(c.birthday,INTERVAL (YEAR(NOW())-YEAR(c.birthday)+1) YEAR) <= '2011-03-12 00:00:00' ) 

你可能感兴趣的:(sql,C++,c,mysql,C#)