Skip to main content
Hi,

 

we have field managers in different timezones creating case records. (Case is a custom object.)

 

We would like to report at what hour of the day most cases get created based on the creator's time. 

 

I created a report with a formula field to pull the hour of the day. But this will create a report based on the current user's timezone. The hour should be based on the user's timezone who has created those records.

 

Theoretically, the creator of the records is related to the object, so the timezone can be pulled, but how? Any idea how to solve that?

 

Thanks,

 

Mario

 

 

 

Formula field to get the hour:

 

HOUR(TIMEVALUE(CObject__c.Created_Date_Date_with_Timestamp__c)) 
10 answers
  1. Michael Brown (Salesforce) Forum Ambassador
    Oct 12, 2020, 8:22 PM
    I played around with this, and this formula may actually be better because it should be able to handle negative or positive offsets. For example, America/Mexico_City is 5 hours behind GMT. If it's 2:00 AM GMT, 5 hours behind this should be 9:00 PM CDT or 21:00 CDT.  In the formula above, it would take 2 - 5 and return -3, which we would want it to return 21. 

     

    To get around that, this formula should work: 

    CASE(CreatedBy.TimeZoneSidKey,

    "America/Los_Angeles",TEXT(MOD(VALUE(MID(TEXT(CreatedDate),FIND(":",TEXT(CreatedDate),1)-2,2))+17,24)),

    "America/Mexico_City",TEXT(MOD(VALUE(MID(TEXT(CreatedDate),FIND(":",TEXT(CreatedDate),1)-2,2))+19,24)),"")

     

    Here I'm introducing the MOD function so that the number returned is always 0-24 for the 24 hour clock.  For timezones that are prior to GMT, you take the offset and subtract from 24.  For example, Los_Angeles is 7 hours behind GMT, so I'm taking 24-7=17. I'm then adding that in the MOD function and dividing by 24. 

     

    If I had a time zone that was ahead of GMT, I would instead find the offset in how many hours ahead. For example, if I had an Australian time zone that was 8 hours ahead of GMT, I would take 24-8=16 and subtract this value and divide by 24, which would look something like this:

    CASE(CreatedBy.TimeZoneSidKey,

    "Australia/Perth",TEXT(MOD(VALUE(MID(TEXT(CreatedDate),FIND(":",TEXT(CreatedDate),1)-2,2))-16,24)),"")

    I did some testing with this formula and the results appear to be correct on my end using the MOD function. Below is a table with the 24 hour time in GMT, followed by the corresponding time in various time zones:

     

    I played around with this, and this formula may actually be better because it should be able to handle negative or positive offsets. For example, America/Mexico_City is 5 hours behind GMT.