Take the 2-minute tour ×
Salesforce Stack Exchange is a question and answer site for Salesforce administrators, implementation experts, developers and anybody in-between. It's 100% free, no registration required.

There is a Date Field whose value is I gave as 15th Oct 2014. When I insert the same, Is this an absolute time value irrespective of any Time-Zone; does it matter who inserted the Date field? I have user X from timezone: GMT 05:30 and another user Y from timezone: GMT -8:00. We both insert two records of an SObject called 'DateObject' that has a Date field called datefield__c. Does it store differently if X wrote this statements instead of Y?

Date myDate = Date.valueOf('2012-12-25 00:00:00');
insert myDate;

Please clarify. Thanks

share|improve this question

2 Answers 2

SF stores all DateTimes in UTC. Some Native applications handle this conversion for you, but there are use cases where you have to handle the conversion yourself. From the documentation...

Remember that dateTime field values are stored as Coordinated Universal Time (UTC). When one of these values is returned in the Salesforce application, it is automatically adjusted for the timezone specified in your organization preferences. Your application may need to handle this conversion.

http://www.salesforce.com/us/developer/docs/officetoolkit/Content/sforce_api_calls_soql_select_dateformats.htm

As to point out every single use case where you would have to handle this conversion, I do not know. I know that personally, I have run across it when trying to use DateTime fields in Formulas. I had to handle the conversion to my TimeZone myself.

Here is a SFSE question in which I show this actually. This is not meant to help answer the question, but just to give you an idea of a use case where I had to handle the conversion myself.

Case Report grouped by Hour of Day

share|improve this answer

Apart from how the dates are stored in the database, this is how I always understood how datetimes / timezones work in Salesforce:

Scenario: entering the "same" datetime in a field by users with different timezones

  • when a user fills a datetime field of 4 PM, this means he is entering the datetime as 4 PM in HIS timezone (GMT 05:30) . The system then will indeed store this as to what that datetime corresponds to in UTC

  • when a user would fill a datetime field with 4 PM, but his user has a different timezone - let's say GMT 02:00, then offcourse, the value stored in the database will NOT be the same as from the first user. This is normal as this second user is living and thinking in the GMT 02:00 timezone and not in the GMT 05:30 timezone... Again here, Salesforce will then convert the 4 PM GMT 02:00 to UTC.

So if you had your users entering datetime information and then you noticed that your users had incorrect settings for their timezone, the datetime values stored in the database will be wrong.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.