[SalesForce] Wrong Date value when using formula DATEVALUE(DateTime)

I have two fields EVENT_DATE(type DateTime) and EDate(type Date).
I am using a workflow to get Date value from EVENT_DATE and store it in EDate.
Workflow formula :- DATEVALUE(EVENT_DATE).
The workflow fires at record creation time or anytime record is updated.

however i have noticed that the value for EDate in some of the records is not correct.

Example :2015-05-13T22:47:41.000Z is gives 14-05-2015 using the DATEVALUE formula.

This is causing real trouble for our users.

Is there any way to correct this without having to Update all the the data?
Any solution in the form of configuration or code is welcome.

Best Answer

DATEVALUE() Returns a year, month, day in GMT time value while DATE() returns a year, month, day based on a User's time zone. It would appear that's the cause of your issue. The formula is evaluated based on the context of the running user.

DateTime values are stored in the Salesforce Database in GMT time and they're displayed to a user in the user's local time zone per the time zone settings in their User profile. What YOU see when looking at them is based on YOUR User Profile time zone, not the User who scheduled the Event. Perhaps if you check the event date times in GMT and compare the DATEVALUES, you may discover that they're being converted properly. You may also want to check the User Profile settings where these discrepancies are being reported.

I say this because if someone with the wrong user Time Zone in their profile kicks off the workflow, the conversion to GMT will be made incorrectly and this error will propagate to all users when they view the change.

Related Topic