"Operand type clash: int is incompatible with date"

0

This code is very basic ... Could you help me?

create database Escuela

create table Maestros 
(
  usuario int not null,
  name varchar(50),
  country char(2),
  birthdate date
);

insert into Maestros values (1, 'Emmanuel', 'MX', 1996-07-23);

I get a syntax error

Msg 206, Level 16, State 2, Line 1
Operand type clash: int is incompatible with date
    
asked by Task-Force-23 08.04.2016 в 06:56
source

1 answer

2

The problem is here, in the last parameter:

insert into Maestros values (1, 'Emmanuel', 'MX', 1996-07-23);

instead of 1996-07-23 must be '1996-07-23' , look at the quotes. Without the sql quotes it will interpret this date as a number, specifically it will try to calculate 1996 - 7 - 23 = 1966. And that is the error message that you see there, it tells you that you are trying to assign a number ( int ) to a date ( date ).

    
answered by 08.04.2016 / 07:00
source