---
schema_version: "1"
id: 86a36d8c8426fe484478c4dbd1b2d2f1f5bf4709872e6fe14a22b939e32e94d9
title: Primitive Data Types
collection: legacydeveloper
version: current
locale: en-us
portal_url: https://docs.salesforce.com/legacydeveloper/current/en-us/object_reference/primitive_data_types.md
canonical_url: https://developer.salesforce.com/docs/atlas.en-us.object_reference.meta/object_reference/primitive_data_types.htm
source_site: developer.salesforce.com
content_type: documentation
content_hash: 2695829746afbe2b2212ffd446dfff352a0d4aff0f028ffc7fce417d2421a96d
---
# Primitive Data Types

The API uses the following primitive data types:

<table class="featureTable sort_table" summary="">


        <thead class="thead sorted" align="left">
          <tr>
            <th class="featureTableHeader  " id="d16113e43">Value</th>

            <th class="featureTableHeader  " id="d16113e46">Details</th>

          </tr>

        </thead>

        <tbody class="tbody">
          <tr>
            <td class="entry" headers="d16113e43" data-title="Value"><span class="ph" id="i1435003"><a name="i1435003"><!-- --></a>base64</span></td>

            <td class="entry" headers="d16113e46" data-title="Details">Base 64-encoded binary data. Fields of this type are used for storing binary files in
              Attachment records, Document records, and Scontrol records. In these objects, the
              <span class="keyword parmname">Body</span> or <span class="keyword parmname">Binary</span> field contains the (base64 encoded)
              data, while the <span class="keyword parmname">BodyLength</span> field defines the length of the data in the
              <span class="keyword parmname">Body</span> or <span class="keyword parmname">Binary</span> field. In the Document object, you
              can specify a URL to the document instead of storing the document directly in the
              record.
            </td>

          </tr>

          <tr>
            <td class="entry" headers="d16113e43" data-title="Value"><span class="ph" id="i1435021"><a name="i1435021"><!-- --></a>boolean</span></td>

            <td class="entry" headers="d16113e46" data-title="Details">Boolean fields have one of these values: <samp class="codeph nolang">true</samp> (or
              1), or <samp class="codeph nolang">false</samp> (or 0).</td>

          </tr>

          <tr>
            <td class="entry" headers="d16113e43" data-title="Value"><span class="ph" id="i1435026"><a name="i1435026"><!-- --></a>byte</span></td>

            <td class="entry" headers="d16113e46" data-title="Details">A set of bits.</td>

          </tr>

          <tr>
            <td class="entry" headers="d16113e43" data-title="Value"><span class="ph" id="i1435031"><a name="i1435031"><!-- --></a>date</span></td>

            <td class="entry" headers="d16113e46" data-title="Details">Date data. Fields of this type contain date values, such as
              <span class="keyword parmname">ActivityDate</span> in the Event object. Unlike dateTime fields, date fields
              contain no time value—the time portion of a date field is not relevant and is always
              set to midnight in the Coordinated Universal Time (UTC) time zone.<p class="p">If you specify a date
                value in a query, you can filter on date fields only.</p>
            </td>

          </tr>

          <tr>
            <td class="entry" headers="d16113e43" data-title="Value"><span class="ph" id="i1435039"><a name="i1435039"><!-- --></a>dateTime</span></td>

            <td class="entry" headers="d16113e46" data-title="Details">Date/time values (timestamps). Fields of this type handle date/time values
              (timestamps), such as <span class="keyword parmname">ActivityDateTime</span> in the Event object or the
              <span class="keyword parmname">CreatedDate</span>, <span class="keyword parmname">LastModifiedDate</span>, or
              <span class="keyword parmname">SystemModstamp</span> in many objects. Regular dateTime fields are full
              timestamps with a precision of one second. They are always transferred in the Coordinated
              Universal Time (UTC) time zone.<span class="ph" id="datetime_conversion_info"><a name="datetime_conversion_info"><!-- --></a> In your client
                application, you might need to translate the timestamp to or from a local time
                zone.</span>
              <p class="p">If you specify a dateTime value in a query, you can filter on dateTime fields
                only.</p>
              <p class="p"><span class="ph" id="TimeDataTools"><a name="TimeDataTools"><!-- --></a>Development tools differ in the way that they handle
                  time data. Some development tools report the local time, while others report only the
                  Coordinated Universal Time (UTC) time zone. To determine how your development tool handles
                  time values, refer to its documentation.</span></p>
              <p class="p">The Event object has a
                <span class="keyword parmname">DurationInMinutes</span> field that specifies the number of minutes for an
                event. Even though this is a temporal value, it is an integer type—not a dateTime
                type.
              </p>
            </td>

          </tr>

          <tr>
            <td class="entry" headers="d16113e43" data-title="Value"><span class="ph" id="i1435061"><a name="i1435061"><!-- --></a>double</span></td>

            <td class="entry" headers="d16113e46" data-title="Details">Double values. Fields of this type can contain fractional portions (digits to the right
              of the decimal place), such as <span class="keyword parmname">ConversionRate</span> in CurrencyType. In the
              API, all non-integer values (such as <a class="xref" href="https://developer.salesforce.com/docs/atlas.en-us.object_reference.meta/object_reference/field_types.htm#i1435541">Currency Field
                Type</a> and <a class="xref" href="https://developer.salesforce.com/docs/atlas.en-us.object_reference.meta/object_reference/field_types.htm#i1435698">Percent Field Type</a>) contain values of type double. Some
              restrictions may be applied to double values: <ul class="ul bulletList">
                <li class="li">
                  <span class="keyword parmname">scale</span>: Maximum number of digits to the right of the decimal
                  place.
                </li>

                <li class="li">
                  <span class="keyword parmname">precision</span>: Total number of digits, including those to the left and
                  the right of the decimal place
                </li>

              </ul>
              <p class="p">The maximum number of digits to the left of the decimal place is equal to
                <span class="keyword parmname">precision</span> minus <span class="keyword parmname">scale</span>. In the Salesforce user
                interface, precision is defined differently—it is the maximum number of digits allowed to
                the left of the decimal place.
              </p>
              <p class="p"><span class="ph" id="double_scientific_notation"><a name="double_scientific_notation"><!-- --></a>Values can be
                  stored in scientific notation if the number is large enough (or, for negative numbers,
                  small enough), as indicated by the <a class="xref" href="http://www.w3.org/TR/xmlschema-2/#double" target="_blank" title="HTML (New Window)">W3C XML Schema Part 2: Datatypes
                    Second Edition specification</a>.</span></p>
              <p class="p">When the user sets the precision in custom
                fields in the Salesforce application, it displays the precision set by the user, even if the
                user enters a more precise value than defined for those fields. However, when you set the
                precision in custom fields using the API, no rounding occurs when the user retrieves the
                number field.</p>
            </td>

          </tr>

          <tr>
            <td class="entry" headers="d16113e43" data-title="Value"><span class="ph" id="i1435108"><a name="i1435108"><!-- --></a>int</span></td>

            <td class="entry" headers="d16113e46" data-title="Details">Fields of this type contain numbers with no fractional portion (digits to the right of
              a decimal place), such as the <span class="keyword parmname">NumberOfEmployees</span> in an Account. For
              integer fields, <span class="keyword parmname">digits</span> specifies the maximum number of digits that an
              int can have.</td>

          </tr>

          <tr>
            <td class="entry" headers="d16113e43" data-title="Value">long</td>

            <td class="entry" headers="d16113e46" data-title="Details">Large integers. They are similar to the int type but can hold a wider range of numbers.
              The smallest possible value for long is -9223372036854775808 and the largest possible value
              is 9223372036854775807. For long fields, <span class="keyword parmname">digits</span> specifies the maximum
              number of digits that the number can have.</td>

          </tr>

          <tr>
            <td class="entry" headers="d16113e43" data-title="Value"><span class="ph" id="i1435116"><a name="i1435116"><!-- --></a>string</span></td>

            <td class="entry" headers="d16113e46" data-title="Details">Character strings. Fields that are of data type <samp class="codeph nolang">string</samp> contain text and some have length restrictions depending on the data being
              stored. For example, in the Contact object, the <span class="keyword parmname">FirstName</span> field is 40
              characters, the <span class="keyword parmname">LastName</span> field is 80 characters, the
              <span class="keyword parmname">MailingStreet</span> is 255 characters.<p class="p">For fields that contain strings,
                behavior is different beginning with API version 15.0. In API versions previous to 15.0, if
                you specify a value for a field, and that value is too large, the value is truncated. For
                API version 15.0 and later, if a value is specified that is too large, the operation fails
                and the fault code <samp class="codeph nolang">STRING_TOO_LONG</samp> is returned. <span class="ph" id="allowfieldtrunc_def"><a name="allowfieldtrunc_def"><!-- --></a>AllowFieldTruncationHeader allows you to specify that the previous
                  behavior, truncation, be used instead of the new behavior in API versions 15.0 and later.
                  This header has no effect in versions 14.0 and earlier. The affected fields are: anyType,
                  email, encryptedstring, multipicklist, phone, picklist, string, and textarea.</span>
              </p>
            </td>

          </tr>

          <tr>
            <td class="entry" headers="d16113e43" data-title="Value"><span class="ph" id="timeField"><a name="timeField"><!-- --></a>time</span></td>

            <td class="entry" headers="d16113e46" data-title="Details">Time values. Fields of this type handle time values, such as
              <span class="keyword parmname">FridayEndTime</span> in the BusinessHours object, with a precision of one
              millisecond.<p class="p">Development tools differ in the way that they handle time data. Some
                development tools report the local time, while others report only the Coordinated Universal
                Time (UTC) time zone. To determine how your development tool handles time values, refer to
                its documentation.</p>
            </td>

          </tr>

        </tbody>

      </table>

These data types are used in the SOAP messages that are exchanged between your client application and the API. When writing your client application, follow the data typing rules defined for your programming language and development environment. Your development tool handles the mapping of typed data in your programming language with these SOAP data types.

The primitive data types are:

- specified in the World Wide Web Consortium’s publication _XML Schema Part 2: Data Types_ at the following URL: [http://www.w3.org/TR/xmlschema-2/](http://www.w3.org/TR/xmlschema-2/).
- enumerated in the SOAPType field of the Field type, which is described in the fields property of the DescribeSObjectResult.

Primitive types are used as a standardized way to define, send, receive, and interpret basic data types in the SOAP messages exchanged between client applications and the API. In addition, primitive data types are interpreted in a Salesforce-specific way, which is useful for display formatting and for numeric conversion (adding values of different currencies).

For example, Salesforce chooses to interpret a double value passed via SOAP as a double in a number of possible ways, depending on the field definition. If the field type for that data is currency, Salesforce handles the display of the data by prepending it with a currency symbol and inserting a decimal for precision. Similarly, if the field type is percent, Salesforce handles the display of the data by appending a percent sign (%). Regardless of the field type, however, the value is sent in the SOAP message as a double.

The API uses data types called field types that are defined in the WSDLs. For more information, see [Field Types](https://developer.salesforce.com/docs/atlas.en-us.object_reference.meta/object_reference/field_types.htm "In addition to the primitive data types, the API defines the following data types for fields.").