SQL Server: learned that you can pass a Style to CAST and CONVERT (Transact-SQL)
Posted by jpluimers on 2014/03/19
Funny way to learn something new:
I hardly use CAST and CONVERT (Transact-SQL), and when I do, it is the standard SQL-92 way.
But a while ago, I came across some code like this:
CONVERT(DATETIME, "31/12/2013", 105);
and wondered what the 105 was.
And it appeared to convert from the Italian date format to DateTime. And that it has been there since at least SQL Server 2000, probably earlier.
Not sure why the passed slashes (/) in stead of dashes (-) as separators though.
There are styles for these groups of conversions:
- Binary
- Date/Time
- Float/Real
- Money/Smallmoney
- XML
Never to old to learn something new (:
–jeroen
Leave a Reply