Formula for calculating number of hours between 2 Date/Time fields

Problem: I am trying to figure out the time in hours it takes for a Lead to be contacted after the Lead record is created

Steps Taken:

1- Created a custom read-only Date/Time field called First_Contacted_Date__c

2- Built a Flow that sets the First_Contacted_Date__c to the date/time the first Task is completed

Where I Am Stuck:

The final part I need to solve is to create a number formula field on the Lead that calculates the number of hours between the 2 Date/Time fields First_Contacted_Date__c and CreatedDate.

Does not need to be business hours, just the total hours. I have found ways to create a text field that calculates number of business hours. But ideally, we need the number of hours as a number field.

Does anyone know if this is possible and how it can be done?

Thank you so much!

Just take the two fields, subtract them, and divide by 24 (subtraction calculates days):

``````(First_Contacted_Date__c-CreatedDate)/24
``````
• Is there a way to get the decimal places to show up as well? For instance 0.5 hours = 30 min etc. When I use this formula and put the decimal places as 2, I get no value for the decimal Commented Oct 19, 2022 at 20:22
• Please disregard. I got it: (DATETIMEVALUE(First_Contacted_Date__c) - DATETIMEVALUE(CreatedDate))*24 Commented Oct 19, 2022 at 20:44

You can use something like this -

``````VALUE(TEXT)
``````

It will convert text into number

• The other approach could be - if difference between number of days is less than 1, other wise you can use add 24*number . `HOUR(TIMEVALUE(First_Contacted_Date__c ) - HOUR(TIMEVALUE(CreatedDate)))` Commented Oct 19, 2022 at 18:53
• Is there a way to get the decimal places to show up as well? For instance 0.5 hours = 30 min etc. When I use this formula and put the decimal places as 2, I get no value for the decimal Commented Oct 19, 2022 at 20:32
• Please disregard. I got it: (DATETIMEVALUE(First_Contacted_Date__c) - DATETIMEVALUE(CreatedDate))*24 Commented Oct 19, 2022 at 20:44

VALUE( TEXT(HOUR( TIMEVALUE(Out__c) ) - HOUR(TIMEVALUE(IN__c) )) + '.' + TEXT(IF( MINUTE(TIMEVALUE(Out__c)) < MINUTE(TIMEVALUE(IN__c)) , MINUTE(TIMEVALUE(IN__c)) - MINUTE(TIMEVALUE(Out__c)) , MINUTE(TIMEVALUE(Out__c)) - MINUTE(TIMEVALUE(IN__c)))) )

With this formula you can calculate the exact time between 2 date/time data type