Click here to Skip to main content
15,918,889 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
create table emp (eno int,ename varchar(50),esal money,edoj date,ecity varchar(50));


insert into emp values(1001, 'Ramu', 10000, 10/01/2016, 'Delhi');


Error :
Msg 206, Level 16, State 2, Line 1
Operand type clash: int is incompatible with date

What I have tried:

create table emp (eno int,ename varchar(50),esal money,edoj date,ecity varchar(50));

insert into emp values(1001, 'Ramu', 10000, 10/01/2016, 'Delhi');


Error :
Msg 206, Level 16, State 2, Line 1
Operand type clash: int is incompatible with date
Posted
Updated 25-Nov-16 17:59pm
Comments
Richard Deeming 25-Nov-16 14:12pm    
NB: Using a culture-specific date format for date literals will have unintended consequences. The date literal 10/01/2016 could be interpreted as 10th January or 1st October, depending on the server's settings.

It's always best to use an invariant format for date literals: '20160110'

Try This
SQL
create table emp (eno int,ename varchar(50),esal money,edoj date,ecity varchar(50));
insert into emp values(1001, 'Ramu', 10000, '10/01/2016', 'Delhi');

Also Please read documentation CAST and CONVERT (Transact-SQL)[^]
 
Share this answer
 
v2
Comments
Member 12870881 28-Nov-16 11:56am    
Thank you for your response.... Answer is executed successfully...

Thank you very much manu_dhobale
Try 'yyyy-mm-dd' format

'2016/01/10' with the ' before and after.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900