function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
TobyDogTobyDog 

Activity Hour Time Stamp - Daylight Savings Accounted For

I have an interesting one for you.  

We want to create a text field that will show the hour activity record was created and an "A.M. or P.M." after it, however it needs to compensate for Daylight Saving Time.    

I have created the formula however, it is hard coded to either Eastern Standard Time or Daylight Savings.  

I need help with the logic that would combine both into the same field.  I think adding a simple IF statement would work but I am not sure how to fit it in.

-  

Here is the formula for EST and EDT below.  Daylight Savings is this year from 3/9/2014 to 11/2/2014.  Thanks for your help!    

EST:

Text(CASE(VALUE(MID(TEXT( CreatedDate ) , 12, 2)), 00 , 7,
01 , 8,
02 , 9,
03, 10,
04 , 11,
05 , 12,
06 , 1,
07 , 2,
08 , 3,
09 , 4,
10 , 5,
11 , 6,
12 , 7,
13 , 8,
14 , 9,
15 , 10,
16 , 11,
17 , 12,
18 , 1,
19 , 2,
20 , 3,
21 , 4,
22 , 5,
23 , 6, 24))
& IF(AND(VALUE(MID(TEXT( CreatedDate ) , 12, 2)) > 4, VALUE(MID(TEXT( CreatedDate ) , 12, 2)) < 17), " a.m.", " p.m.")

EDT:

Text(CASE(VALUE(MID(TEXT( CreatedDate ) , 12, 2)), 00 , 8,
01 , 9,
02 , 10,
03, 11,
04 , 12,
05 , 1,
06 , 2,
07 , 3,
08 , 4,
09 , 5,
10 , 6,
11 , 7,
12 , 8,
13 , 9,
14 , 10,
15 , 11,
16 , 12,
17 , 1,
18 , 2,
19 , 3,
20 , 4,
21 , 5,
22 , 6,
23 , 7, 24))
& IF(AND(VALUE(MID(TEXT( CreatedDate ) , 12, 2)) > 4, VALUE(MID(TEXT( CreatedDate ) , 12, 2)) < 17), " a.m.", " p.m.")

Ashish_SFDCAshish_SFDC
Hi , 


However, since time zones can be affected by Daylight Saving Time, and the start and end dates for DST are different each year, this is difficult to manage in a formula. We recommend using Apex for transactions that require converting between Date/Time values and Text or Date values.

http://www.salesforce.com/us/developer/docs/usefulFormulaFields/Content/formula_using_date_datetime.htm


I would recommend use seperate formulas and concatenate the result. 


Regards,
Ashish