Problem with SQL server smalldatetime insert query

I have a field:

APP_DATE (smalldatetime)

I am making this request:

INSERT INTO table (TYPE, CODE, APP_DATE, DATE) VALUES ('APP', '123', '02/10/2010 12.30', GETDATE())

Fails:

Msg 296, Level 16, State 3, Line 1
Conversion from datatype char to smalldatetime generated a value not between the interval of valid values.
Instruction has been interrupted.

(0 row(s) affected)

What am I doing wrong? It seems to me that this is the correct format for the field.

Thank you for your time.

EDIT: SQL Server 2000

+3
source share
5 answers

Just use :in due time instead .. Then he will insert a penalty.

+4
source

Can you try using the ISO-8601 date format (YYYYMMDD HH: MM: SS) - this will always work on SQL Server - regardless of your regional and local settings:

INSERT INTO table (TYPE, CODE, APP_DATE, DATE) 
VALUES ('APP', '123', '20100210 12:30:00', GETDATE())
+5
source

; 4 ( ), .

2003/01/22 22:31 . . .

+2
source

insert into the values โ€‹โ€‹yourTable (yourSmallDateTimeColumn) ('1900-01-01 11:45:23'); // format "yyyy-MM-dd HH: mm: ss"

+1
source

If you do not need a time element in the SQL Server field, by default it will be 00:00:00 for you if you just send '02 / 10/2010 '. If you need a time element, then your format for time is incorrect in your example, and it should be something like this - '02 / 10/2010 12:31:00 '

0
source

Source: https://habr.com/ru/post/1734063/


All Articles