Newer Version Available

This content describes an older version of this product. View Latest

FORMAT ()

Use FORMAT with the SELECT clause to apply localized formatting to standard and custom number, date, time, and currency fields.

When the FORMAT function is applied, fields reflect the appropriate format for the given user locale. The field format matches what appears in the Salesforce Classic user interface. For example, the date December 28, 2015 can appear numerically as 2015-12-28, 28-12-2015, 28/12/2015, 12/28/2015, or 28.12.2015, depending on the org’s locale setting.

In this example, dates are returned in ISO 8601 format such as 2025-04-10T22:31:37.000+0000.

1SELECT lastModifiedDate FROM Opportunity
If lastModifiedDate is wrapped in FORMAT, the date returned is in the org or user's locale, such as 4/10/2025, 3:31 PM.
1SELECT FORMAT(lastModifiedDate) FROM Opportunity

Using FORMAT with currencies returns a fully formatted value, such as $44,000.00, instead of a plain number.

1SELECT FORMAT(Amount) FROM Opportunity
The FORMAT function supports aliasing. In addition, aliasing is required when the query includes the same field multiple times. For example:
1SELECT Id, LastModifiedDate, FORMAT(LastModifiedDate) formattedDate FROM Account
You can also nest it with aggregate or convertCurrency() functions. For example:
1SELECT amount, FORMAT(amount) Amt, convertCurrency(amount) editDate, FORMAT(convertCurrency(amount)) convertedCurrency FROM Opportunity where id = '12345'
2SELECT FORMAT(MIN(closedate)) Amt FROM opportunity