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 the “BirthDate” column to display as a long date.

SELECT Format(BirthDate, “Long Date”AS FormattedBirthDate
FROM Employees;

Definition and Usage

The FORMAT() function formats a date value according to the specified format.

Syntax

Format(valueformatfirstdayofweekfirstweekofyear)

Parameter Values

Parameter

Description

value

Mandatory. The date value that will be formatted according to the specified format.

format

Optional. Specifies the format in which the date value will be displayed or converted.

FORMAT

DESCRIPTION

General Date

Displays the value as a date according to the current system configuration.

Long Date

Displays the value formatted as a date according to the system’s long date settings.

Medium Date

Displays the value formatted as a date according to the system’s medium date settings.

Short Date

Displays the value formatted as a date according to the system’s short date settings.

Long Time

Displays the value formatted as a date according to the system’s long time settings.

Medium Time

Displays the value formatted as a date according to the system’s medium time settings.

Short Time

Displays the value formatted as a date according to the system’s short time settings.

 

firstdayofweek

Specifies the optional setting for the first day of the week, which can be defined using the following values:

  • 0: Use the NLS API setting
  • 1: Sunday (default)
  • 2: Monday
  • 3: Tuesday
  • 4: Wednesday
  • 5: Thursday
  • 6: Friday
  • 7: Saturday

firstdayofyear

Specifies an optional setting for the first week of the year, with the following values:

  • 0: Use the NLS API setting
  • 1: Use the first week that includes January 1st (default)
  • 2: Use the first week in the year that has at least 4 days
  • 3: Use the first full week of the year

Technical Details

WORKS IN

From Access 2000