Three key aspects underlie almost every inspection, audit, and compliance use case: date, time, and location. From scheduling to identifying deficiencies, these three come up in almost every aspect of reporting and documentation.
This post will be focused on two of those three elements, Date and Time. Salesforce has specific rules for handling these fields and they are important to understand to ensure you are entering and viewing this information in a way that makes sense to you and your stakeholders. At first glance, they seem pretty straightforward (as indicated below), but they can be a bit confusing to work with in the beginning:
- Date – Allows users to enter a date or pick a date from a popup calendar.
- Time – Allows users to enter a local time. For example, “2:40 PM”, “14:40”, “14:40:00”, and “14:40:50.600” are all valid times for this field.
- Date/Time – Allows users to enter a date and time, or pick a date from a popup calendar. When users click a date in the pop-up, that date and the current time are entered into the Date/Time field.
To demystify the process and help you to make the best use of these fields, our team at MB&A developed the following Q&A:
1. How are Date, Time, and Date/Time fields stored?
In both the ExAM mobile app and the Salesforce UI, date/time have an associated time zone, while the time field is set in a static mode and records whatever time is populated.
In ExAM, the time zone defaults to the one that is configured on the data collection device (e.g., iPhone, iPad, Android phone, Android tablet).
For Salesforce, the time zone is set in accordance with the one the allocated to the user in Setup.
Hence, when the user enters a date/time combination in ExAM or Salesforce, it is based on that time zone, not necessarily the one where the user is located. From there, Salesforce stores it in the database in GMT.
To be clear, date field entries are static fields that are stored in the date format.
2. How are Date, Time, and Date/Time fields displayed to the user?
Salesforce calculates and displays date/time fields in the user’s specified time zone. This display appears in several locations, including individual records and reporting, ExAM Document Designer reports, and in the ExAM mobile app.
Since time is recorded and stored within static fields, intervals are displayed exactly as the user entered them, while dates are stored in a standard format.
3. When I pull up the corresponding report, why is my creation date/time different from the date and time field I recorded?
That very question is why I wrote this article. It is quite possible to enter a date/time into your mobile app and then see a different one displayed on the Salesforce user interface or in related reports. For this to occur, you need only view the field in the Salesforce UI or in a report while the user setup indicates a different zone.
This can be even more confusing if you are using a mix of Date, Time, and Date/Time fields. Whereas the values captured in the Date and Time fields are static and reflect exactly what was entered, the Date/Time field indicates the time zone that was set by the user.
Examples of Date and Time vs. Date/Time
In the following section, we will provide some examples that include what the user capturing the data sees vs. what a user viewing a reporting in Salesforce may see.
Where it was captured: ExAM4Inspections Mobile
- Field type: Date
- The user sees…The date entered
- UI/report viewer sees…The date, as it was recorded on the mobile device
Where it was captured: ExAM4Inspections Mobile
- Field type: Time
- The user sees…The time entered
- UI/report viewer sees…The time, as it was recorded on the mobile device
Where it was captured: ExAM4Inspections Mobile
- Field type: Date/Time
- The user sees…The date/time in the time zone set on the mobile device
- UI/report viewer sees…The date/time entered in the mobile device and adjusted for the viewer’s time zone
Where it was captured: Salesforce UI
- Field type: Date
- The user sees…The date entered
- UI/report viewer sees…The date entered
Where it was captured: Salesforce UI
- Field type: Time
- The user sees…The time entered
- UI/report viewer sees…The time entered
Where it was captured: Salesforce UI
- Field type: Date/Time
- The user sees…The date/time in the time zone in [words missing]
- UI/report viewer sees…The date/time entered by the user in accordance with their time zone and adjusted for the viewer’s time zone