Date Format in Salesforce

How Salesforce decides which date format to show, which text formats it expects in imports, SOQL, formulas and Apex, and how to convert extracted dates safely.

What this guide covers

There are two separate questions behind "date format in Salesforce." The first is how dates appear on screen. The second is which text format Salesforce expects when you give it a date, for example in an import file, a query, a formula or code. These are controlled by different settings. Mixing them up is the most common cause of swapped days and months. This guide covers both. It also explains how to turn dates pulled from free text into a format Salesforce reads reliably.

Note on sources: no organization-specific or release-specific evidence was supplied for this article. The explanations below rely on long-standing, generally documented Salesforce behavior. Menu labels and tool options can change between releases and editions, so check them in your own org before relying on them.

Display format versus stored value

Salesforce stores a date as a value, not as formatted text. What you see on a record page, list view or report is that value rendered according to the viewing user's Locale setting. The same record can therefore show a date one way to a user with a US locale and another way to a user with a UK or German locale. The stored value is identical in both cases.

The practical consequence: changing how a date looks does not require changing any data. Display format is a per-user preference. It is not a field property.

Date fields and Date/Time fields

A Date field holds only a calendar day. A Date/Time field holds a moment in time. Salesforce stores Date/Time values in UTC (Coordinated Universal Time) and converts them to each user's time zone for display. A Date/Time can therefore appear to fall on a different calendar day for users in different time zones. A plain Date field does not shift this way.

If you only need the day, such as a birthday, contract start or due date, a Date field avoids time zone surprises.

Changing the date display format step by step

Salesforce does not offer a free-form "date pattern" setting for display. You change the format by choosing a different locale.

  • For your own user: open your personal Settings, go to My Personal Information, then Language & Time Zone.
  • Change the Locale value to the region whose date convention you want, then save.
  • For the org default: an administrator sets Default Locale under Company Information in Setup. New users inherit this default.
  • For another user: an administrator can edit the Locale field on that user's record.
  • Reload a record that contains a date and confirm the new rendering.

Locale also affects number and currency separators and name order. Review those before changing the org-wide default. Language is a separate setting from Locale, so you can keep English labels with a non-US date convention.

Text formats Salesforce expects as input

When you send dates to Salesforce as text, the safest format is ISO 8601 (an international standard that writes year, month and day in that order). Several input contexts require it, and none of them misreads it.

Context | Expected text format | Illustrative example
SOQL Date literal | YYYY-MM-DD, unquoted | WHERE CloseDate = 2024-03-05
SOQL Date/Time literal | YYYY-MM-DDThh:mm:ssZ, or with a +hh:mm / -hh:mm offset | WHERE CreatedDate > 2024-03-05T00:00:00Z
Apex Date.valueOf(String) | yyyy-MM-dd | Date.valueOf('2024-03-05')
Formula TEXT() of a Date | Returns YYYY-MM-DD | TEXT(CloseDate)
Data Loader CSV | yyyy-MM-dd is unambiguous; slash formats depend on the tool's date setting | 2024-03-05

SOQL also accepts relative date literals such as TODAY, YESTERDAY and LAST_N_DAYS:30. These avoid hard-coded date text entirely.

Data Loader has a setting for European date format. With that setting on, slash-separated dates are read day-first instead of month-first. Other import tools may interpret dates using the importing user's locale. Check the documentation for the tool you use. Converting to yyyy-MM-dd first removes the question.

Formatting a date as text in a formula

TEXT() on a Date gives year-month-day. To build a different layout, combine YEAR(), MONTH() and DAY(). Then pad single digits with LPAD() so that March appears as 03 rather than 3. Illustrative formula producing day.month.year:

LPAD(TEXT(DAY(CloseDate)), 2, "0") & "." &
LPAD(TEXT(MONTH(CloseDate)), 2, "0") & "." &
TEXT(YEAR(CloseDate))

The result is a Text value, not a Date. It will not sort or filter chronologically, and it will not adapt to each user's locale. Use it for display or export labels, not as a replacement for the date field.

For the reverse direction, DATEVALUE() converts suitable text, or a Date/Time, into a Date. DATE(year, month, day) builds a Date from numbers. Building with DATE() is more predictable than parsing arbitrary text.

Formatting dates in Apex

In Apex, Date.format() returns the date in the running user's locale. For a fixed pattern, use DateTime.format(pattern). It accepts Java-style pattern letters. Illustrative, untested snippet:

Date d = Date.valueOf('2024-03-05');
String localeText = d.format();

Datetime dt = Datetime.newInstance(d, Time.newInstance(0, 0, 0, 0));
String fixedText = dt.format('dd.MM.yyyy');

Capitalization in patterns changes meaning. MM is month, while mm is minutes. dd is day of month, while DD is day of year. yyyy is the calendar year, while YYYY is the week-based year, which can differ around New Year. Copy patterns exactly.

Datetime.format(pattern) renders in the running user's time zone. Datetime.formatGmt(pattern) renders in GMT. Pick the one that matches what the consumer of the text expects.

Converting dates extracted from text before import

If your dates come from emails, PDFs or spreadsheets, convert them to yyyy-MM-dd before loading them. Apply the conversion only to the column or field that holds the date. Running a find-and-replace over whole rows can alter IDs, phone numbers or notes that happen to contain slashes and digits.

Illustrative Python example, not verified against your data. It converts month-first US dates such as 3/5/2024 to 2024-03-05 and adds zero padding:

import re

US_DATE = re.compile(r'^(\d{1,2})/(\d{1,2})/(\d{4})$')

def to_iso(value):
    m = US_DATE.match(value.strip())
    if not m:
        return None  # leave for manual review
    month, day, year = (int(g) for g in m.groups())
    return f"{year:04d}-{month:02d}-{day:02d}"

The pattern is anchored with ^ and $. This means it only accepts a cell that is entirely a date and will not rewrite dates embedded in longer text. Values that do not match return None so you can review them, rather than being silently changed. The example does not check calendar validity, so 2/30/2024 would pass. Add a real date check, for instance by parsing with a date library, if your source may contain bad values.

Ambiguity is the main risk. 03/05/2024 is March 5 to a US reader and 3 May to many European readers. No regular expression can decide this from the text alone. Confirm the source convention first, for example by finding a value with a day above 12 in the same column. Then apply the matching conversion to the whole column.

Verifying the result

  • Pick a test date with a day above 12, such as the 25th, so a day/month swap is obvious.
  • After changing Locale, open a record and confirm the date renders in the expected order.
  • Before a bulk import, load a few rows and compare the saved values with the source file.
  • In SOQL or Apex, query the test record by its ISO date and confirm it is returned.
  • For Date/Time data, check the value as a user in a different time zone to confirm the day does not shift unexpectedly.

Known gaps

This guide does not list the exact rendering for each locale, because no verified samples were supplied. The examples above are illustrative and were not run against a live org. Setting names and import tool options should be confirmed in your Salesforce edition and current release documentation.