function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion

Timestamps before 1911 are incorrectly stored in DB: 1900-01-01 10:00:00 -> 1900-01-01 09:50:39



this is kind of weird.

If you try to set any DateTime field in a Salesforce database Object to a Timestamp before 1911-03-01, the time portion of the Timestamp is stored incorrectly in the field. Try this:


Event myEvent = new Event();
myEvent.ActivityDateTime = DateTime.newInstance(1900, 1, 1, 10, 0, 0);
myEvent.DurationInMinutes = 20;
myEvent.Subject= 'testevent';
upsert myEvent;

Now execute a query in e.g. Explorer (any other platform than apex code):

select ActivityDateTime from Event where Subject='testevent'

 the content of the ActivityDateTime Field differs from the value set in Apex code: 1900-01-01 10:00:00 -> 1900-01-01 09:50:39


This is reproduceable for every TimeStamp field on standard or custom objects.


If you fire the query in Apex the value shown is correct. The error only occurs for third party tools that are reading the data directly from Salesforce without using Apex.


Is this a well known behavior or a new bug?

Best Answer chosen by Admin (Salesforce Developers) 

I will answer it by myself.


The problem only occurs if the user is in the Europe/Paris timezone.


a) According to the TimeAndDate website ( GMT was the universal reference standard, but the French continued to treat Paris as the prime meridian until 1911. Even so, the French defined legal time as Paris Mean Time minus nine minutes and 21 seconds.


b) This means that creating an instance of Datetime in the local time (Datetime.newInstance()) when the timezone is Europe/France and the year is 1900-1911, will be equivalent to select timezone GMT minus 9 minutes and 21 seconds. So 10:00:00 in French's time in 1900 is 10:00:00-00:09:21 = 9:50:39 in GMT


this explains the strange 9:21 difference