我累了这个
select CONVERT(DATE, '31/12/18', 103) as rDatum
但我收到错误:
Conversion failed when converting date and/or time from character string.
在TSQL中将短日期的字符串转换为DATE的正确方法是什么?
答案 0 :(得分:4)
你非常亲密......
这是british/french format with a 2-digit year。格式代码为3
(103
年份为4位数)
试试这个
select CONVERT(DATE, '31/12/18', 3) as rDatum
答案 1 :(得分:1)
试试这个
SET DATEFORMAT DMY
INSERT INTO targetTable (rDatum, col2 etc)
SELECT CAST(someDate AS DATE) , col2 etc
FROM sourceTable