SQL Server: the conversion of a varchar data type to a datetime data type resulted in an out-of-range value -
i want insert date , time in 2 ways shown below:
table: ft
create table ft ( columndate datetime, columntime datetime )
insertion of records: format 1
insert ft values('2014-12-25', '01:55:56');
insertion of records: format 2
insert ft values('25-12-2014', '01:45:54');
note: yeah! of course want insert date first column columndate
, time second column columntime
, want use datetime
datatype that. both format of insertion getting same error shown below:
error:
the conversion of varchar data type datetime data type resulted in out-of-range value.
it conversions , datatypes.
first, implicit conversion dangerous. know, take @ link: how sql server decide format implicit datetime conversion?
i use format: 'yyyymmdd hh:mm:ss'
it not problem store day, suggested in comment, recommend use date type , time type.
store time in datetime type not possible. if, reason, need this, must in old days, when datetime type usable, , insert time default date, 19000101.
this:
insert ft values('2014-12-25', '01:55:56');
will like:
insert ft values('20141225', '19000101 01:55:56');
Comments
Post a Comment