Lokasi ngalangkungan proxy:   [ UP ]  
[Ngawartoskeun bug]   [Panyetelan cookie]                
Skip to content

Commit b9a88bd

Browse files
authored
Removed some noise.
1 parent 0ca05b9 commit b9a88bd

1 file changed

Lines changed: 25 additions & 32 deletions

File tree

docs/t-sql/functions/format-transact-sql.md

Lines changed: 25 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ Returns a value formatted with the specified format and optional culture. Use th
3030
## Syntax
3131

3232
```syntaxsql
33-
FORMAT ( value, format [, culture ] )
33+
FORMAT( value, format [, culture ] )
3434
```
3535

3636
[!INCLUDE[sql-server-tsql-previous-offline-documentation](../../includes/sql-server-tsql-previous-offline-documentation.md)]
@@ -96,60 +96,56 @@ FORMAT ( value, format [, culture ] )
9696
The following example returns a simple date formatted for different cultures.
9797

9898
```sql
99-
DECLARE @d DATETIME = '10/01/2011';
100-
SELECT FORMAT ( @d, 'd', 'en-US' ) AS 'US English Result'
101-
,FORMAT ( @d, 'd', 'en-gb' ) AS 'Great Britain English Result'
102-
,FORMAT ( @d, 'd', 'de-de' ) AS 'German Result'
103-
,FORMAT ( @d, 'd', 'zh-cn' ) AS 'Simplified Chinese (PRC) Result';
104-
105-
SELECT FORMAT ( @d, 'D', 'en-US' ) AS 'US English Result'
106-
,FORMAT ( @d, 'D', 'en-gb' ) AS 'Great Britain English Result'
107-
,FORMAT ( @d, 'D', 'de-de' ) AS 'German Result'
108-
,FORMAT ( @d, 'D', 'zh-cn' ) AS 'Chinese (Simplified PRC) Result';
99+
DECLARE @d DATE = '11/22/2020';
100+
SELECT FORMAT( @d, 'd', 'en-US' ) 'US English'
101+
,FORMAT( @d, 'd', 'en-gb' ) 'Great Britain English'
102+
,FORMAT( @d, 'd', 'de-de' ) 'German'
103+
,FORMAT( @d, 'd', 'zh-cn' ) 'Simplified Chinese (PRC)';
104+
105+
SELECT FORMAT( @d, 'D', 'en-US' ) 'US English'
106+
,FORMAT( @d, 'D', 'en-gb' ) 'Great Britain English'
107+
,FORMAT( @d, 'D', 'de-de' ) 'German'
108+
,FORMAT( @d, 'D', 'zh-cn' ) 'Chinese (Simplified PRC)';
109109
```
110110

111111
[!INCLUDE[ssResult](../../includes/ssresult-md.md)]
112112

113113
```
114-
US English Result Great Britain English Result German Result Simplified Chinese (PRC) Result
115-
---------------- ----------------------------- ------------- -------------------------------------
116-
10/1/2011 01/10/2011 01.10.2011 2011/10/1
114+
US English Great Britain English German Simplified Chinese (PRC)
115+
---------- --------------------- ---------- ------------------------
116+
11/22/2020 22/11/2020 22.11.2020 2020/11/22
117117
118-
(1 row(s) affected)
118+
US English Great Britain English German Chinese (Simplified PRC)
119+
--------------------------- ---------------------- -------------------------- ---------------------------------------
120+
Sunday, November 22, 2020 22 November 2020 Sonntag, 22. November 2020 2020年11月22日
119121
120-
US English Result Great Britain English Result German Result Chinese (Simplified PRC) Result
121-
---------------------------- ----------------------------- ----------------------------- ---------------------------------------
122-
Saturday, October 01, 2011 01 October 2011 Samstag, 1. Oktober 2011 2011年10月1日
123-
124-
(1 row(s) affected)
125122
```
126123

127124
### B. FORMAT with custom formatting strings
128125

129126
The following example shows formatting numeric values by specifying a custom format. The example assumes that the current date is September 27, 2012. For more information about these and other custom formats, see [Custom Numeric Format Strings](https://msdn.microsoft.com/library/0c899ak8.aspx).
130127

131128
```sql
132-
DECLARE @d DATETIME = GETDATE();
133-
SELECT FORMAT( @d, 'dd/MM/yyyy', 'en-US' ) AS 'DateTime Result'
134-
,FORMAT(123456789,'###-##-####') AS 'Custom Number Result';
129+
DECLARE @d DATE = GETDATE();
130+
SELECT FORMAT( @d, 'dd/MM/yyyy', 'en-US' ) AS 'Date'
131+
,FORMAT(123456789,'###-##-####') AS 'Custom Number';
135132
```
136133

137134
[!INCLUDE[ssResult](../../includes/ssresult-md.md)]
138135

139136
```
140-
DateTime Result Custom Number Result
141-
-------------- --------------------
142-
27/09/2012 123-45-6789
137+
Date Custom Number
138+
---------- -------------
139+
22/11/2020 123-45-6789
143140
144-
(1 row(s) affected)
145141
```
146142

147143
### C. FORMAT with numeric types
148144

149145
The following example returns 5 rows from the **Sales.CurrencyRate** table in the [!INCLUDE[ssSampleDBnormal](../../includes/sssampledbnormal-md.md)] database. The column **EndOfDateRate** is stored as type **money** in the table. In this example, the column is returned unformatted and then formatted by specifying the .NET Number format, General format, and Currency format types. For more information about these and other numeric formats, see [Standard Numeric Format Strings](https://msdn.microsoft.com/library/dwhawy9k.aspx).
150146

151147
```sql
152-
SELECT TOP(5)CurrencyRateID, EndOfDayRate
148+
SELECT TOP(5) CurrencyRateID, EndOfDayRate
153149
,FORMAT(EndOfDayRate, 'N', 'en-us') AS 'Number Format'
154150
,FORMAT(EndOfDayRate, 'G', 'en-us') AS 'General Format'
155151
,FORMAT(EndOfDayRate, 'C', 'en-us') AS 'Currency Format'
@@ -168,14 +164,12 @@ CurrencyRateID EndOfDayRate Numeric Format General Format Currency Format
168164
4 1.4683 1.47 1.4683 $1.47
169165
5 8.2784 8.28 8.2784 $8.28
170166
171-
(5 row(s) affected)
172-
173167
```
174168

175169
This example specifies the German culture (de-de).
176170

177171
```sql
178-
SELECT TOP(5)CurrencyRateID, EndOfDayRate
172+
SELECT TOP(5) CurrencyRateID, EndOfDayRate
179173
,FORMAT(EndOfDayRate, 'N', 'de-de') AS 'Numeric Format'
180174
,FORMAT(EndOfDayRate, 'G', 'de-de') AS 'General Format'
181175
,FORMAT(EndOfDayRate, 'C', 'de-de') AS 'Currency Format'
@@ -192,7 +186,6 @@ CurrencyRateID EndOfDayRate Numeric Format General Format Currency Format
192186
4 1.4683 1,47 1,4683 1,47 €
193187
5 8.2784 8,28 8,2784 8,28 €
194188
195-
(5 row(s) affected)
196189
```
197190

198191
### <a name="ExampleD"></a> D. FORMAT with time data types

0 commit comments

Comments
 (0)