34,874
社区成员
发帖
与我相关
我的任务
分享
select *
from hr_leave_form f
where user_id = 133
and delete_flag = 0
and convert(smalldatetime,start_date + ' ' + start_time) <= convert(smalldatetime,str(20130311) + ' 11:00')
and convert(smalldatetime,end_date + ' ' + end_time) >= convert(smalldatetime,str(20130311)+ ' 10:00')
[/quote]
首先除了楼上我之外的蠢货都不认真看题
其次我这个蠢货写错了个东西
and ISDATE(smalldatetime,start_date + ' ' + start_time)=1
应该是
and ISDATE(start_date + ' ' + start_time)=1[/quote]
你和楼主都被盗号了吧。
你描红的条件好像也没用,优先级问题,ISDATE(start_time)=1[/quote]
优先级和执行计划都一回事了
判断相加后的和单独判断时间也一样的。[/quote]
小爱蝈蝈辛苦啦,发完贴看好下午搬家,没来得及看,
这种问题为啥很正常呢? 讲几个原因?
我也用相同的数据做测试表测试了,就没报错。为啥正式环境就报错了。
其他回答问题的,再自己看看题目
[/quote]
首先除了楼上我之外的蠢货都不认真看题
其次我这个蠢货写错了个东西
and ISDATE(smalldatetime,start_date + ' ' + start_time)=1
应该是
and ISDATE(start_date + ' ' + start_time)=1[/quote]
你和楼主都被盗号了吧。
你描红的条件好像也没用,优先级问题,ISDATE(start_time)=1[/quote]
优先级和执行计划都一回事了
判断相加后的和单独判断时间也一样的。[/quote]
真的不行了。
下面是我测试的
declare @tab table(a smalldatetime,b varchar(10))
insert into @tab values('20130429 10:00',' :00')
select a+b from @tab where ISDATE(b)=1 and CONVERT(smalldatetime,a+b)<=CAST(getdate() as smalldatetime)
/*
(1 行受影响)
消息 295,级别 16,状态 3,第 4 行
将字符串转换为 smalldatetime 数据类型时失败。
*/
[/quote]
这种方式也不是很好使,也是会有可能出现错误的,比如这位写的例子
应该用case when 的方式去处理最恰当了
declare @tab table(a smalldatetime,b varchar(10))
insert into @tab values('2013-04-28 00:00:00',':00'),('2013-04-29 00:00:00','10:00')
select * from @tab where CONVERT(smalldatetime,a+case when ISDATE(b)=1 then b else '00:00' end)<=CAST(getdate() as smalldatetime)
[/quote]
首先除了楼上我之外的蠢货都不认真看题
其次我这个蠢货写错了个东西
and ISDATE(smalldatetime,start_date + ' ' + start_time)=1
应该是
and ISDATE(start_date + ' ' + start_time)=1[/quote]
你和楼主都被盗号了吧。
你描红的条件好像也没用,优先级问题,ISDATE(start_time)=1[/quote]
优先级和执行计划都一回事了
判断相加后的和单独判断时间也一样的。[/quote]
真的不行了。
下面是我测试的
declare @tab table(a smalldatetime,b varchar(10))
insert into @tab values('20130429 10:00',' :00')
select a+b from @tab where ISDATE(b)=1 and CONVERT(smalldatetime,a+b)<=CAST(getdate() as smalldatetime)
/*
(1 行受影响)
消息 295,级别 16,状态 3,第 4 行
将字符串转换为 smalldatetime 数据类型时失败。
*/
select *
from hr_leave_form f
where user_id = 133
and delete_flag = 0
and convert(smalldatetime,start_date + ' ' + start_time) <= convert(smalldatetime,str(20130311) + ' 11:00')
and convert(smalldatetime,end_date + ' ' + end_time) >= convert(smalldatetime,str(20130311)+ ' 10:00')
[/quote]
首先除了楼上我之外的蠢货都不认真看题
其次我这个蠢货写错了个东西
and ISDATE(smalldatetime,start_date + ' ' + start_time)=1
应该是
and ISDATE(start_date + ' ' + start_time)=1[/quote]
你和楼主都被盗号了吧。
你描红的条件好像也没用,优先级问题,ISDATE(start_time)=1[/quote]
优先级和执行计划都一回事了
判断相加后的和单独判断时间也一样的。[/quote]
呵呵,那就一样吧,当我什么也没说。
[/quote]
首先除了楼上我之外的蠢货都不认真看题
其次我这个蠢货写错了个东西
and ISDATE(smalldatetime,start_date + ' ' + start_time)=1
应该是
and ISDATE(start_date + ' ' + start_time)=1[/quote]
你和楼主都被盗号了吧。
你描红的条件好像也没用,优先级问题,ISDATE(start_time)=1[/quote]
优先级和执行计划都一回事了
判断相加后的和单独判断时间也一样的。
[/quote]
首先除了楼上我之外的蠢货都不认真看题
其次我这个蠢货写错了个东西
and ISDATE(smalldatetime,start_date + ' ' + start_time)=1
应该是
and ISDATE(start_date + ' ' + start_time)=1[/quote]
你和楼主都被盗号了吧。
你描红的条件好像也没用,优先级问题,ISDATE(start_time)=1
[/quote]
神马意思
[/quote]
首先除了楼上我之外的蠢货都不认真看题
其次我这个蠢货写错了个东西
and ISDATE(smalldatetime,start_date + ' ' + start_time)=1
应该是
and ISDATE(start_date + ' ' + start_time)=1