Curriculum
Course: SQL
Login

Curriculum

SQL

SQL References

0/80

MySQL Functions

0/139

SQL Server Functions

0/84

SQL Quick Ref

0/1
Text lesson

Format

Example

Format a numeric expression as a percentage.

SELECT Format(0.5“Percent”AS FormattedNum;

Definition and Usage

The Format() function formats a numeric value according to the specified format.

Syntax

Format(valueformat)

Parameter Values

Parameter

Description

value

Required: The numeric value that you want to format.

format

Optional: The specific format to apply.

 

Format

Description

General Number

Specifies a number without including thousand separators

Currency

Indicates currency, with thousand separators and two decimal places

Fixed

Displays at least one digit to the left of the decimal point and two digits to the right

Standard

Displays thousand separators, with at least one digit to the left of the decimal point and two digits to the right

Percent

Displays a percentage value with two digits to the right of the decimal point, including the percent sign.

Scientific

Represents scientific notation

Yes/No

Displays “No” if the value equals 0, and “Yes” if the value is not equal to 0.

True/False

Displays “False” if the value equals 0, and “True” if the value is not equal to 0.

ON/Off

Displays “Off” if the value equals 0, and “On” if the value is not equal to 0.

Technical Details

Works in:

 From Access 2000

More Examples

Example

Format the “Price” column as currency.

SELECT Format(Price, “Currency”AS FormattedPrice
FROM Products;