SQL Server Convert string to Date Format in SQL [closed]

azpvetkf  于 2023-10-15  发布在  其他
关注(0)|答案(1)|浏览(115)

Closed. This question is not reproducible or was caused by typos . It is not currently accepting answers.

This question was caused by a typo or a problem that can no longer be reproduced. While similar questions may be on-topic here, this one was resolved in a way less likely to help future readers.

Closed 19 days ago.
Improve this question

I am trying to convert a string to a date using the function shown here, but I get an error. What could be the issue?

SELECT
    CONVERT(date, '2023-05-26T18.48.01.6425261+05.30', 103)

This is the error I get:

Conversion failed when converting date and/or time from character string.

gg58donl

gg58donl1#

For your specific case, and it means - the string data you have, NOTHING will work. You need to adjust your data from

'2023-05-26T18.48.01.6425261+05.30'

to

'2023-05-26T18:48:01.6425261+05:30'

And then use style 127 , then it will work

Select CONVERT(date, '2023-05-26T18:48:01.6425261+05:30', 127)

It will work with different styles as well but only in relation to the datatype you converting to.

相关问题