DateTime conversion

I'm drawing a blank on this one, not sure if I need more coffee or not. Can anyone explain why I'm getting Conversion failed when converting date and/or time from character string error?

declare @d nvarchar(30) = '2021-11-31 15:33:30.5033333'

select convert(datetime, @d, 21)

You have too much precision for a datetime, which has only .sss.

You need datetime2 to have 7 subsecond digits.

Off the top of my head. Checking now on what the "21" format code is.

...11-31... there are only 30 days in Nov.

2 Likes

who needs a calendar. I can just make up days :slight_smile:
Thanks for the help, I knew I needed more coffee

1 Like