al4629740
asked on
Conversion failed when converting the varchar value to data type int.
I get the following error:
Conversion failed when converting the varchar value 'December' to data type int.
for the following sql string
select * from frmRegistrationCSW where Fiscal = 2013 and Month(EntryTime) ='December'
and frmRegistrationCSWCheck11 = 1
How do I convert it?
Conversion failed when converting the varchar value 'December' to data type int.
for the following sql string
select * from frmRegistrationCSW where Fiscal = 2013 and Month(EntryTime) ='December'
and frmRegistrationCSWCheck11 = 1
How do I convert it?
ASKER
How can I change Month(EntryTime)?
I would like to keep it as ='December'
I would like to keep it as ='December'
Then you can do it like this
Datename (mm,[EntryTime]) ='December'
Datename (mm,[EntryTime]) ='December'
ASKER
Does that work if I do this, using the < symbol
Datename (mm,[EntryTime]) <= 'December'
Datename (mm,[EntryTime]) <= 'December'
No, it will not wotk, Better you need to convert it into int and use it.
you can make a case statement if it is december then return 12 and can use it here.
you can make a case statement if it is december then return 12 and can use it here.
ASKER
Why do both of this statements produce different results?
select * from frmRegistrationCSW where Fiscal = 2013 and EntryTime <= '12/31/2012' and frmRegistrationCSWCheck11 = 1
select * from frmRegistrationCSW where Fiscal = 2013 and Datename (mm,[EntryTime]) <= 'December' and frmRegistrationCSWCheck11 = 1
I don't think that would make sense (because doing a character comparison). Month(EntryTime)<=12 would normally make more sense except that generally that should always be true (I am unaware of any month being greater than 12 :-)). Perhaps you would like to describe what it is you are trying to achieve?
ASKER
Case statement?
Do you have an example?
Do you have an example?
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Make it like Month(EntryTime) =12 then it will work