The result of the fDate formula is passed into the Convert Date to Datetime Flow ActionĪnd finally, the difference between the two Datetime values is calculated, converted to hours and passed back to the calling Flow. You can call this sub-flow anywhere you need to get the offset to use in Datetime value calculations for the User’s time zone.Ī Date Variable is created for Input and a Number Variable is created for Output.Ī Formula is used to assign a default value of Today if no date value is passed into the flow. Here’s a sample sub-flow I created that you could use to get the User’s GMT Offset for any date. IF( AND($User.Southern_Hemisphere_c, NOT(ISBLANK( $User.Summertime_Start_Offset_c ))),1,0)>23,24,0)Īndy figured out that taking the difference between the Datetime returned by my component (midnight GMT) and the Datetime returned by the Flow formula DATETIMEVALUE(Date) you would get the GMT Offset for that date based on the running User’s time zone. IF(HOUR(TIMEVALUE(CreatedDate+(1+ $User.GMT_Offset_c )/24)) IF( AND($User.Southern_Hemisphere_c, NOT(ISBLANK( $User.Summertime_Start_Offset_c ))),1,0) HOUR(TIMEVALUE(CreatedDate+(1+ $User.GMT_Offset_c )/24)) IF(HOUR(TIMEVALUE(CreatedDate+ $User.GMT_Offset_c /24)) +IF( AND($User.Southern_Hemisphere_c, NOT(ISBLANK( $User.Summertime_Start_Offset_c ))),1,0) HOUR(TIMEVALUE(CreatedDate+$User.GMT_Offset_c /24)) (WEEKDAY(DATE(YEAR(DATEVALUE(CreatedDate)),MONTH($User.Wintertime_start_Date_c),DAY($User.Wintertime_start_Date_c)))-1))+$User.Wintertime_Start_Offset_c/24 ISBLANK( $User.Summertime_Start_Offset_c ),ĭATETIMEVALUE(DATE(YEAR(DATEVALUE(CreatedDate)),MONTH($User.Wintertime_start_Date_c),DAY($User.Wintertime_start_Date_c)) Here’s an example presented by Eric Praud on Jen Lee’s “ How I Solved This” Admin Podcast where he created a new custom object, added 9 custom fields to the User object and came up with this formula to get the hour of the day when converted to the User’s local time: IF( OR( Admins have created very complex formulas trying to calculate an offset based on the User’s State or Country but then they ran into issues trying to handle Daylight Savings Time adjustments as well. You are unable to use a formula in Salesforce to determine a User’s time zone. Recently, Andy Engin Utkan, figured out a way to use this component to overcome issues he was having when using a Display Text component in a Flow when trying to show Datetime values and have them display in the correct time zone. This setting is located on the Time Zone tab.įor operating systems other than Microsoft Windows, please check your system’s Help function for instructions.A couple of years ago, I created a component to convert a Date value to a Datetime value in a Flow.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |