This project is read-only.

 


 

fn_format (Transact_SQL)

See also: none

 


This scalar UDF formats the given value to a named format. Compatibility with FORMAT function of SQL 2012 will be added
 

Syntax

 fn_max_val(@vaue,@format,@culture)

 

Arguments

@value = sql_variant, value to be formated with @format named format;

@format = NVARCHAR(255), named format to apply for value.

@culture = NVARCHAR(255), not used added for compatibility with SQL 2012 FORMAT() function.

 

 

Return type

 NVARCHAR(4000)

Remarks

Formats accepted: 

 

GENERAL NUMBER = 2345.678

FIXED = 2345.67

STANDARD = 2,345.67

CURRENCY = $2,345.67

PERCENT = 34.23%

GENERAL DATE = 7/20/2012 10:57:00 AM

LONG DATE = Friday, July 20, 2012

MEDIUM DATE = 20-Jul-2012

SHORT DATE = 7/20/2012

LONG TIME = 11:01:34 AM

MEDIUM TIME = 11:01 AM

SHORT TIME = 11:01

TIMESTAMP = 20120801112301

ZIP OR ZIP5 = 12345

ZIP9 OR ZIP+4 = 12345-6789

SSN = 012-34-5678

PHONE = 1 (617) 234-5678

 

 

Permissions

Public

Dependencies

none

 

Examples

SELECT [Lib].[tsql].[fn_format](GETDATE(),'LONG DATE','US-EN')

Result

 Friday, July 20, 2012

 

Other

none




 

Last edited Sep 4, 2012 at 7:10 PM by adudau, version 6

Comments

No comments yet.