34,590
社区成员
发帖
与我相关
我的任务
分享
INSERT INTO Pub_User ([Guid], [Version], [CreateTime]) VALUES (N'794bd01a20b042ca9c02caa24761cd75', 46, '27/05/2013 10:05:51')
drop table aaatime
go
create table aaatime
(timetest datetime)
insert into aaatime values('27/05/2013 10:05:51')--*
insert into aaatime values('27/05/13 10:05:51')
insert into aaatime values('01/02/32 10:05:51')---*
insert into aaatime values('32/02/01 10:05:51')
insert into aaatime values('05/27/2013 10:05:51')
insert into aaatime values('2013-05-29 10:05:51')
insert into aaatime values(convert(datetime,'01/02/32 10:05:51',3))
insert into aaatime values(convert(datetime,'28/05/2013 10:05:51',103))
select * from aaatime
产生的结果是:
务器: 消息 242,级别 16,状态 3,行 1
从 char 数据类型到 datetime 数据类型的转换导致 datetime 值越界。
语句已终止。
(所影响的行数为 1 行)
服务器: 消息 242,级别 16,状态 3,行 1
从 char 数据类型到 datetime 数据类型的转换导致 datetime 值越界。
语句已终止。
(所影响的行数为 1 行)
(所影响的行数为 1 行)
(所影响的行数为 1 行)
(所影响的行数为 1 行)
(所影响的行数为 1 行)
(所影响的行数为 6 行)
可以试试把底下这句,将3改为1,用美国式,看看是几月几日。32改成03,再把最后一个3改成11或1或3,试试,挺有趣的
insert into aaatime values(convert(datetime,'01/02/32 10:05:51',3))
select langid,dateformat
from sys.syslanguages
where name=@@LANGUAGE
CONVERT ( data_type [ ( length ) ] , expression [ , style ] )
Without century (yy) With century (yyyy) Standard Input/Output**
3 103 British/French dd/mm/yy
* The default values (style 0 or 100, 9 or 109, 13 or 113, 20 or 120, and 21 or 121) always return the century (yyyy).
** Input when converting to datetime; output when converting to character data.
*** Designed for XML use. For conversion from datetime or smalldatetime to character data, the output format is as described in the table. For conversion from float, money, or smallmoney to character data, the output is equivalent to style 2. For conversion from real to character data, the output is equivalent to style 1.
****Hijri is a calendar system with several variations, of which Microsoft® SQL Server™ 2000 uses the Kuwaiti algorithm.
如果是美国,那么是1,或101?2楼