+ Start a Discussion
nothingisreal68nothingisreal68 

Same Date Formula displays different values on View Page and Related list

I have a formula field that is converting a date/time into just a date. Based on conditional logic, this formula attempts to take the Datevalue() of a datetime.

 

On the problem record, the value of the datetime field is "5/1/2013 12:00 AM".

 

When viewing the standard view page for this record, the formula correctly displays "5/1/2013".  When I navigate to a related list that displays the same formula field, however, the value shown is "4/30/2013".

 

Why would the exact same field display differently in a related list and on a standard view? I have been able to reproduce this in several orgs with brand new sObjects. My current user is in the eastern time zone. This same issue seems to happen regardless of the time zone my user is in.

 

Steps to reproduce:

1. Create a brand new object "Parent"

2. Create another object, "Child".

3. On the child record, create three fields:

    1) a lookup field to the parent object.

    2) a datetime field, "Datetime 1" that is a sample field.

    3) a formula field, "Formula Field" that returns the datevalue of the other created field. The formula should be:

 

            Datevalue(Datetime_1__c)

 

4. Create a record of the parent object. 

5. Create a record of the child object. Populate the Datetime 1 field with 5/1/2013 12:00 AM and save the record. Notice that the formula field correctly displays "5/1/2013".

6. Navigate to the parent record and view the child record in the related list. Note that "Datetime 1" displays correctly, but "Formula Field" now shows "4/30/2013."

 

 

In my tests, when the value of the datetime field is set to "1:00 AM" instead, the formula displays correctly in both places. It seems like on related lists, SFDC does not taken into account Daylight Savings Time when converting Datetimes to Dates in formulas.

 

 

 

T-HanT-Han

I don't think so it has to do with the Daylight.. As if you wanna dig deeper then Date/Time can get very complex and very interesting as well.

 

Here in your case. Time is the factor, keeping the date as yours of 5/1/2013 - and times 12:01PM, 11:59PM and 12:00PM will give you 5/1/2013 on the RL of Parent. But, 12:00AM - is a spot which is kinda still 4/30/2013 ..  

 

And you are taking the Datevalue - which means its calculating based on the whole Date and Time and 5/1/2013 - 12:00 AM is 4/30/2013.. If you change the date to 5/2 : 12 AM it will be 5/1 in RL.

 

I know that the Parent obj shows the date you  would like. If that is the case you wanna maintain, the best thing to do is. Create a field like Copy Formula Date Field and Copy the Calculated Date to that and HIDE the original Formula field. And use the new field in Related list.

 

Lemme know,,

 

Chris760Chris760

Maybe since the webpage is being sent to you at the speed of light, the parent record is in the future, but the child record is in the past?  O_o

 

Actually all joking aside, did you know that the clocks on satellites, actually run slower due to their speed as they circle the Earth, so they have to design the clocks to run just slightly "faster" so that they'll run at the same speed as the clocks on the ground?  Just something interesting I read in popular mechanics about a year back.

 

On to your question though... I think the problem might be related to the fact that the Date-Time clock on the Salesforce server actually runs on Zulu time, which is like -8 or something, and completely ignores daylight savings time.  Like, try converting the date time to text and you'll get a totally weird time value where you'll be like "where the f*** did that come from?".  When you do really elaborate formulas with dates and times, these bizarre factors come to light.

 

You must be doing something different with the child formula, but I can't see your code, so I don't have the foggiest idea what you're actually doing differently.  But my hunch tells me that you're referencing a value in a slightly different way on the child record, in which the current date-time in Zulu puts the day technically 1 day behind the current date -- since it's not yet the following day in zulu time.

 

Typically the "zulu errors" (as I call them), don't actually surface unless you're converting a date or a date time over to text or some other format and then back to a date or date time.  But you might have some weird scenario... not sure.  I'd have to see it, and have you explain what type of field that every custom field in your formula is referencing.