tsql - How to convert time String to datetime? -


i want convert string datetime.

so i'm building code:

select convert(datetime, '23:00', 103) 

if try execute code have this:

1900-01-01 23:00:00.000

but if try execute convert:

select convert(datetime, '24:00', 108) 

i have error:

converting varchar data type datetime generated value not within range of allowed values.

datetime type not support "24th hour". time range 00:00:00 through 23:59:59.997.

try use instead

select convert(datetime, '00:00', 108) 

for more details check datetime (transact-sql) page.


Comments

Popular posts from this blog

Sort a complex associative array in PHP -

vb.net - How to ignore if a cell is empty nothing -

recursion - Can every recursive algorithm be improved with dynamic programming? -