# Exact Time Difference Between two Salesforce Time difference field

I'm trying to create an SF formula field in which we going to return the difference between my two-time field as Start time and End time. I know one approach to calculate the difference showing it as (End_Time__c - Start_Time__c )/ 3600000. But the issue with this as it's not giving exactly the difference of time in a minute.

Any help would be appreciated. thanks in Advance

Choose the output data type for your formula field to number with decimal 0.

The formula you used will give you the output in hours. As the start_time__c and end_time__c are both of TIME data type-

example- start time= 1 AM end time= 3 AM

so the general difference between 2 fields will be 7200000 milliseconds and

to convert that to seconds divide 7200000 milliseconds by 1000 = gives 7200 seconds

to convert that to minutes divide 7200 seconds by 60 = gives 120 minutes

and if you want to convert that to hours divide 120 minutes by 24 = gives 2 hours.

so the formula for your query to get the result in minutes will be

``````(End_Time__c - Start_Time__c )/ 60000
``````