5

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 ?

  • 1
    Are you working on a default page or with a VF page with a custom controller (or extension)? – rael_kid Oct 7 '14 at 6:46
  • No. actually i need a formula which i should write in a formula field. Am not using any pages. – Madhuri Oct 7 '14 at 7:23
  • Actually i need to know about Is it Possible to convert date/time from any timezone to GMT using a formula field. If Possible, please help me how to do that. – Madhuri Oct 7 '14 at 7:24
  • Unfortunately, I think there's no way to do this at the moment. See this question for some more info; salesforce.stackexchange.com/questions/9633/… – rael_kid Oct 7 '14 at 7:41
  • It is not possible to convert date/time from any timezone to GMT using formula field. – Ankush Dureja Oct 7 '14 at 8:32
2

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 )

or

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.

  • Hi, This function is giving result correctly when the time is salesforce time, but it is giving wrong output when the time is our system time,i.e current time. if possible can u please explain this situation – Madhuri Oct 7 '14 at 11:53
  • Can you post the code snippet also. – Aditi Jain Oct 7 '14 at 12:00
  • DATETIMEVALUE("2014-10-07 05:32:00") – Madhuri Oct 7 '14 at 12:02
  • The above one is current time and another code which is working correctly is DATETIMEVALUE(now()) – Madhuri Oct 7 '14 at 12:03
  • @Madhuri Please check my updated answer. That will surely help. – Aditi Jain Oct 8 '14 at 8:55

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.