Wednesday, July 20, 2011

SQL Server Denali Feature Watch - FORMAT(), as in, "OMG we finally get .Net like Number/Date/Time formatting in our TSQL" Or "Saying goodbye to my old friend, Convert(103)..."

Sql&Me - SQL Server – "Denali" – String Formatting using FORMAT()

"SQL Server "Denali" introduces a new function FORMAT() for formatting of DATETIME and numeric values. In Earlier versions we did date and time conversions using CAST and CONVERT as below:


SELECT CONVERT(VARCHAR, @d, 103) AS 'dd/MM/yyyy',
CONVERT(VARCHAR, @d, 104) AS 'dd.MM.yyyy',


FORMAT() uses .NET Framework format string. It can be used as below:


SELECT FORMAT ( @d, 'dd/MM/yyyy') AS 'dd/MM/yyyy',
FORMAT ( @d, 'dd.MM.yyy') AS 'dd.MM.yy',
FORMAT ( @d, 'dd/MMM/yyy') AS 'dd/MMM/yy',
FORMAT ( @d, 'MMM dd, yy') AS 'MMM dd, yy'


image ..."

For some, this feature alone might be worth upgrading. I mean, ZOMG, "real" Date/Time/Number formatting! And best of all, it's the CLR based formatting style too.

For more information, here's the current doc's,

(via SQLServerPedia - SQL Server – "Denali" – String Formatting using FORMAT())


Related Past Post XRef:
SQL Server Denali FileTables Feature - The fruits of WinFS? (Think "A FileStream enabled table that you can access as a network file share and other standard File IO API's" or "SQL Server File System in a Table")
Denali CTP3 introduces LocalDB - Think SQL Server Express crossed with SQL CE (or SQL CE grown up or SQL Express made as almost as easy CE)
SQL Server Denali Sequence Object Overview
A couple SQL Server ColumnStore references...
Time to start thinking about, and providing feedback on, what you’ll need to upgrade to Denali (aka next version of SQL Server)

No comments: