Skip to content

FORMAT

  • value: This is the first parameter of the FORMAT function. It signifies the actual value that is to be formatted. It could be of different types such as date, number or time.
  • format: This is a pattern representing the format to which the value parameter is to be converted. This pattern is specified as a string. For numeral types, it could be patterns such as ‘C’ for currency format. For date and time types, it could be patterns like ‘dd/MM/yyyy’ for date format.
  • culture: This is an optional parameter of the FORMAT function. It is a string that represents a culture setting, which determines the formatting rules to be applied. If this parameter is not specified, the function will use the default culture of the environment where the query is running. For example, ‘en-US’ would format the value according to the United States culture norms.
SELECT FORMAT (getdate(), 'MM/dd/yyyy') as Date;
-------------------
| Date |
-------------------
| 07/20/2022 |
-------------------

The FORMAT function is used in SQL Server to format a date or number according to the specified format. In the example given, the current date is formatted to display in the ‘MM/dd/yyyy’ format.