I have one custom DateTime field named "Transaction Date". While inserting the records I am assigning today's date to Transaction Date.But when I see the record, Transaction Date value is a day lesser. Please help..

  • can share the code used for insertion of records? Jun 26 '15 at 6:19
  • Are you looking at it from a VF page or Developer console? What time zone are you from?
    – highfive
    Jun 26 '15 at 6:20
  • 1
    It is due to your Timezone.. Jun 26 '15 at 6:21

It's because Salesforce stores data in GMT, and you'll need to compensate for it by adding or subtracting however many hours you are from GMT. For example, in California, I have to subtract 8 or 7 depending on DST. See this article: https://developer.salesforce.com/docs/atlas.en-us.apexcode.meta/apexcode/apex_methods_system_timezone.htm


The reason for this is all Date/Time fields are stored in the API as GMT time for data integrity purposes.

What happens when the data is imported in is it converts to the Time Zone and Locale settings of the User that is viewing the Date/Time field in a particular record each time.

The value in salesforce is stored in GMT but while viewing on the UI it adjusts the value to users time zone. Since users time zone is (GMT-04:00) Eastern Daylight Time (America/New_York), it is showing a day lesser. However in the database the value is populated correctly.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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