0

Using CONVERT for datetime whose time part is 24 hours - works. Examples with style codes 101-105:

SELECT CONVERT(datetime, '05/24/2023 23:30', 101)
SELECT CONVERT(datetime, '2023.05.24 23:30', 102)
SELECT CONVERT(datetime, '24/05/2023 23:30', 103)
SELECT CONVERT(datetime, '24.05.2023 23:30', 104)
SELECT CONVERT(datetime, '24-05-2023 23:30', 105)

However, I wonder if this behavior is defined, since the documentation doesn't mention the time part:

Style   Standard        Input/Ouput
101     U.S.            101 = mm/dd/yyyy
102     ANSI            102 = yyyy.mm.dd
103     British/French  103 = dd/mm/yyyy
104     German          104 = dd.mm.yyyy
105     Italian         105 = dd-mm-yyyy

Note that other style codes do mention the time part - so I wonder if using style codes undocumented for 24 hour conversion is a defined behavior, rather than undefined behavior?

1
  • 1
    Interesting find. Methink that the reason that the time oprtion isn't mentioned is when you go the other direction (datetime to char), then the time portion isn't included. But as you say, the doc doesn't state if the time portion is supported to have when you to string-> datetime. I'll pass this on; I'll get back if I get something I can share on this. :-) May 24 at 7:41

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Browse other questions tagged or ask your own question.