Example
1:
DECLARE @mney money = '125000';
SELECT FORMAT ( @mney, 'C') AS MyMoney;
Result:
$125,000.00
Example
2:
DECLARE @mney money = '125000';
SELECT FORMAT ( @mney,'C', 'ta-IN') AS MyMoney;
Result
ரூ 1,25,000.00
Example
3:
DECLARE @mney money = '125000';
SELECT FORMAT ( @mney,'C', 'zh-TW') AS MyMoney;
Result:
NT$125,000.00
Example
4:
set language british
DECLARE @mney money = '125000';
SELECT FORMAT ( @mney, 'C') AS MyMoney;
Result
£125,000.00
Example
5:
DECLARE @num bigint = 5
SELECT FORMAT ( @num, '00.000%') AS MyMoney;
Result:
500.000%
Example
set 1:
SELECT Format(1222.4, '##,##0.00') -- Returns "1,222.40".
SELECT Format(345.9, '###0.00') -- Returns "345.90".
SELECT Format(15, '0.00%') -- Returns "1500.00%".
Example
set 2
DECLARE @date datetime =getdate()
SELECT Format(@date , 'h:m:s') -- Returns "1:10:47".
SELECT Format(@date , 'hh:mm:ss tt') --Returns "01:10:47 AM".
SELECT Format(@date , 'dddd, MMM d yyyy') --Returns "Thursday, Dec
22 2011"
Example
Set 3:
SELECT Format(getdate(), 'M/d/yyyy H:mm tt','en-US') --Returns 12/22/2011 1:14 AM
SELECT Format(getdate(), 'M/d/yyyy H:mm tt zzz','en-US') --12/22/2011
1:15 AM -05:00
No comments:
Post a Comment