I am not familar with sql server why i have the following error
Conversion failed when converting date and/or time from character string.
...
values (1, 'P' + char(10) + 'd' + char(10) + 'inst',
CONVERT(VARCHAR(24),'18-01-2016 11:29:27',113))
the code for 13 is = dd mon yyyy hh:mi:ss:mmm (24h)
is it possible wrong code ?
I checked this answer also didnt work
values (1, 'P' + char(10) + 'd' + char(10) + 'inst',
format('18-01-2016 11:29:27','MM/dd/yyyy HH:mm:ss'))
First of all the target type of CONVERT
should be DATETIME
...
The format code you've tried expects the month as word ( mon
!= mm
)
SELECT CONVERT(DATETIME,'18 jan 2016 11:29:27',113);
You might use one of these:
SELECT CONVERT(DATETIME,'18-01-2016 11:29:27',103)
SELECT CONVERT(DATETIME,'18-01-2016 11:29:27',104)
我相信它作为varchar插入,您可以使用此脚本
SELECT CONVERT(varchar(24),'18-01-2016 11:29:27',120)
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.