Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2005 Forums
 Transact-SQL (2005)
 datetime comparison error.

Author  Topic 

jeff06
Posting Yak Master

166 Posts

Posted - 2009-05-08 : 10:09:54
select count(*)
from Case
where ClosedDate>'/1/31/2009'

Msg 241, Level 16, State 1, Line 1
Conversion failed when converting datetime from character string.

closedate is formated as datetime.
How to solve this problem?
Thanks.
Jeff

khtan
In (Som, Ni, Yak)

17689 Posts

Posted - 2009-05-08 : 10:16:10
specify in YYYYMMDD ISO format

select count(*)
from Case
where ClosedDate>'20090131'


KH
[spoiler]Time is always against us[/spoiler]

Go to Top of Page

madhivanan
Premature Yak Congratulator

22864 Posts

Posted - 2009-05-09 : 01:33:56
You dont need laeding
select count(*)
from Case
where ClosedDate>'1/31/2009'

Madhivanan

Failing to plan is Planning to fail
Go to Top of Page

madhivanan
Premature Yak Congratulator

22864 Posts

Posted - 2009-05-09 : 01:35:57
Also Case is a keyword and better not to use it for naming the objects

Madhivanan

Failing to plan is Planning to fail
Go to Top of Page

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2009-05-09 : 04:38:56
if you want to use it for objects remember to use them within escape characters as
[Case]
Go to Top of Page
   

- Advertisement -