I have a field which calculates opendate-closeddate. It is in IST time zone and i need to display in GMT time whenever it is giving a result.
Is it Possible to convert date/time from any timezone to GMT using a formula field ?
Use this formula function to get DateTime using GMT time zone
DATETIMEVALUE : Returns a year, month, day and GMT time value
This is described in the documentation
Note: Using with function with static date like DATETIMEVALUE(“2014-10-07 13:46:00”) doesn’t seems to be considering Daylight Saving Time (DST).
Above formula will return 10/7/2014 7:16 PM result i.e simply adding 5.30 hours to time.
Above function works fine with DATETIMEVALUE(now())
It is better if you can store actual date to convert in some field and use formula like this:
TEXT( Datetime field )
TEXT( DATETIMEVALUE( Datetime field) )
And the reason behind why you should avoid directly using
DATETIMEVALUE( Datetime field)
in the formula field is because the return type of this formula field would be Date/Time and when salesforce show them on UI, it will convert the representation according to the current logged in user locale.