CONVERT DATE TO DATETIME FLOW ACTION

It’s fairly easy to extract the Date portion of a Datetime value in a Flow formula.

DATEVALUE({!datetimeValue})

If {!datetimeValue} = 7/22/2020 5:00 PM then the formula will return July 22, 2020.

It is a bit trickier to convert a Date value to a Datetime value using a formula. 

DATETIMEVALUE(TEXT({!dateValue}) + ” 00:00:00″)

If {!dateValue} = July 22, 2020 you would want the formula to return 7/22/2020 12:00 AM.  Instead the value returned will be converted to GMT so the result I get in Portland, Maine is 7/21/2020 8:00 PM.  For me, that’s 4 hours ahead of GMT.

I could find no easy way to do time-zone calculations in Flow so I created a Flow Action that would keep everything in my current time-zone.

With this action, my result for July 22, 2020 is 7/22/2020 12:00 AM.

If you want a timestamp of other than 12:00 AM, you can pass in the desired hour, minute and second values.


Attributes

AttributeTypeNotes
Date ValueDateThe Date to be used for the Datetime value
Hour Value (Default = 0)Integer(Optional) The Hour value to be used for the Datetime value (0-23)
Minute Value (Default = 0)Integer(Optional) The Minute value to be used for the Datetime value (0-59)
Second Value (Default = 0)Integer(Optional) The Second value to be used for the Datetime value (0-59)

Use Case

Read about an example that uses this action in a Flow to get the Time Zone offset for the running User.


Install

Created by – Eric Smith – July 2020

Unmanaged v1.0 (Production/Developer)
Unmanaged v1.0 (Sandbox)

Source Code

Source

8 thoughts on “CONVERT DATE TO DATETIME FLOW ACTION

  1. Hello Eric, I finally found the need and the time to use this. This is awesome. I think you should potentially write a new blog post or update this one to show folks that this can be used to find the GMT offset of the timezone the user currently is in. I don’t think this is possible any other way in Salesforce Flow. In summary, I used your action to find the day start time in the user’s timezone and I know flow gives me the day start time in GMT. When I take the difference, I find the correct offset hours I need to use to convert GMT system times by before I display them to the user. Awesome. Here is the result for ET:

    Current Time: 2/16/2022, 6:17 PM

    Day Start: 2/15/2022, 7:00 PM

    User Timezone Day Start: 2/16/2022, 12:00 AM

    GMT offset: 5

    Cheers.

    Liked by 1 person

    1. If you subtract two datetime values you will get the number of days with the fractional amount giving you the hours/minutes. For example 1.5 equals 1 day, 12 hours, 0 minutes.

      Like

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s