有一表 (Table1)如下:
Type (vchar), TheDate(DateTime)
"生日", 1979-1-21
"其它", 2005-1-21求一SQL,列出 Type <> '生日' 并且TheDate = 今天 的数据 和 Type = "生日"TheDate 的月和日等于今天的月和日的SQL.
如果是今天查询的话,2条记录应该全部查询到。
Type (vchar), TheDate(DateTime)
"生日", 1979-1-21
"其它", 2005-1-21求一SQL,列出 Type <> '生日' 并且TheDate = 今天 的数据 和 Type = "生日"TheDate 的月和日等于今天的月和日的SQL.
如果是今天查询的话,2条记录应该全部查询到。
解决方案 »
- Delphi wwDbgrid
- delphi如何实现让控件出现时透明度不断增加的效果?
- 一次最多只能散100?Treeview+Grid(or Table/list)
- [最新收获发布]TListView的ListItem完全自绘
- 散分!准备告别来了两年的delhi版本
- PL的网页如何实现自动提交?我用的填表方法是POST,控件是HttpCli
- 怎么hook一个api函数?用什么hook?最好有示例代码,谢谢!!!
- 用winamp插件功能播放mp3音乐出现的错误,请大家帮我看一看。
- 求一段 dephile 脚本,实现:执行一个exe
- 菜鸟速成(二)
- 我想再注册表里判断一个值,决定系统是否启动的问题
- 数据库连接时间问题
set @Birthday = '2004-01-21'
set @sToday = (select cast(month(getdate()) as varchar(10)) + cast(day(getDate()) as varchar(10)) as Today)
set @sBirth = (select cast(month(@Birthday) as varchar(10)) + cast(day(@Birthday) as varchar(10)) as Birthday)
if @sToday = @sBirth
select 'Today is your Birthday!'
else
select 'Today is not your Birthday!' -------------------------------------
呵呵,up一下
dtMoon
dtDay
select * from Table1
where (Type <> '生日' and TheDate = :dtToday ) or (Type = "生日" and moon(Thedate)=:dtmoon and day(theDay)=:dtDay)呵呵,我不够专业.
--测试数据
Create Table T_Test (T_Name varchar(20),Type varchar(20),TheDate DateTime)
insert T_Test select 'GaoLei','生日','1979-1-21'
union all select 'ZhangSan','其他','2005-1-21'
union all select 'LiSi','UnKown','2001-5-5'
union all Select 'WangWu','生日','1981-2-5'select * from T_Test where
(type <> '生日' and DateDiff(Day,TheDate,GetDate()) = 0)
or
(Type = '生日' and
month(TheDate) = month(GetDate())
and Day(TheDate) = Day(GetDate())
)
Drop Table T_Test--测试结果
T_Name Type TheDate
GaoLei 生日 1979-01-21 00:00:00.000
ZhangSan 其他 2005-01-21 00:00:00.000
(type='生日' and month(theday)=month(getdate()) and day(theday)=day(getdate()))