Sql Server Function FORMAT to format currency, strings, text and numbers for different cultures
- Posted by Sqltimes
- On October 31, 2014
- 0 Comments
Quick one today:
Sql Server has interesting functions; Today we’ll look at one.
Let’s start with a simple example:
1
2
3
4
5
|
-- -- FORMAT function with integer -- SELECT FORMAT(12312312, '#,###,###,###,###' ) GO |
Result:
1
2
3
4
5
6
7
8
9
|
-- -- FORMAT function with date -- DECLARE @DT DATETIME = '2014-10-24' SELECT FORMAT(@DT, 'yyyy/MM/dd' , 'en-US' ) AS [US_Date_with_slash] , FORMAT(@DT, 'd' , 'en-US' ) AS [US_Date_with_hyphen] , FORMAT(@DT, 'D' , 'en-gb' ) AS [GB_Date_with_slash] , FORMAT(@DT, 'd' , 'en-gb' ) AS [GB_Date_with_hyphen] GO |
Read MSDN for more information.
Hope this helps,
_Sqltimes
0 Comments