FORMAT() function in SQL Server 2012/2014

The FORMAT() function is one to really remember, it saves you a lot of time.
Here are a few examples:


SELECT
FORMAT(12345678,'n') AS n
,FORMAT(12345678,'n0') AS n0
,FORMAT(12345678,'n0','nl-NL') AS n0NL
,FORMAT(0.8856,'p') AS p
,FORMAT(0.8856,'p1') AS p1
,FORMAT(12345678,'c') AS c
,FORMAT(12345678,'c1') AS c1
,FORMAT(12345678,'c1','nl-NL') AS c1NL

DECLARE @d DATETIME = '10/01/2011'

SELECT FORMAT ( @d, 'D', 'en-US' ) AS 'US English Result'
,FORMAT ( @d, 'D', 'en-gb' ) AS 'Great Britain English Result'
,FORMAT ( @d, 'D', 'de-de' ) AS 'German Result'
,FORMAT ( @d, 'D', 'zh-cn' ) AS 'Chinese (Simplified PRC) Result';



sql-server-2012-format-function-examples-with-regional-code



For more examples, please visit:
http://www.codeproject.com/Articles/610089/SQL-Servers-FORMAT-function








Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s