Click here to Skip to main content
15,441,629 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
Msg 206, Level 16, State 2, Line 11 Operand type clash: int is incompatible with time
the above error is what popping up every time I try to execute the statement.

What I have tried:

create table USERINFO(
username varchar(20),
country varchar (15),
timeinmin time,
dateofcall date)


insert into USERINFO(username,country,timeinmin,dateofcall)
select 'Bharat','A',12,'11/11/2021'
 
select 'Bharat','A',10,'12/12/2021'
 
select 'Bharat','B',11,'12/13/2021'
 
select 'Bharat','B',1,'12/14/2021'
 
select 'Bharat','B',12,'12/15/2021' 
 
select 'Bharat','C',3,'12/16/2021' 
 
select 'Bharat','C',45, '12/17/2021'
Posted
Updated 10-Dec-21 4:51am
Comments
Надежда Георгиева 2021 10-Dec-21 10:55am    
i think you missed the '10' you have bracelets in syntaxs ;)

time is not int variable to insert it like integer
Think how you will insert a time format ,but not like that way
 
Share this answer
 
Either change the data type used for your column, or change the value you insert into the table to a valid time literal.

Based on the column name, I'm assuming you want the column to be an int containing a number of minutes:
SQL
create table USERINFO
(
    username varchar(20),
    country varchar (15),
    timeinmin int,
    dateofcall date
)
If you really want a time column, your insert needs to be:
SQL
insert into USERINFO (username, country, timeinmin, dateofcall)
values
    ('Bharat', 'A', '0:12', '11/11/2021'),
    ('Bharat', 'A', '0:10', '12/12/2021'),
    ('Bharat', 'B', '0:11', '12/13/2021'),
    ('Bharat', 'B', '0:01', '12/14/2021'),
    ('Bharat', 'B', '0:12', '12/15/2021'),
    ('Bharat', 'C', '0:03', '12/16/2021'),
    ('Bharat', 'C', '0:45', '12/17/2021')
;
time (Transact-SQL) - SQL Server | Microsoft Docs[^]
 
Share this answer
 
v2
Comments
gebriel sirak 10-Dec-21 20:42pm    
thank you it worked and I now got what I missed!

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