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.
ShowAll Questionssorted byDate Posted Vishal Thube

# show Duration hour between two date time field

I Have to show Duration hour between two date time field

First Date – Second Date = Hours:Minutes Vishal Thube

it's 2 Ways Calculate Duration in hours between the two dates time field

First Solution

First Calculate Minutes between two dates. Then convert hours and minutes . using formula field

Calculate Minutes Formula

( Second_Date__c - Frist_Date__C )*24*60

Convert Minutes in Hours

TEXT(FLOOR( Duration__c / 60))
&' Hours '&
TEXT(MOD( Duration__c ,60))
&' Minutes'

Second Solution

Use Formula Field And Use Return Type is Text

IF(FLOOR(MOD((First_Date_Time_c- Second_Date_Time_c )* 24, 24 )) > 0,

TEXT(FLOOR(MOD((First_Date_Time_c- Second_Date_Time_c )* 24, 24 ))) & " Hours ","")

& TEXT(ROUND(MOD((First_Date_Time_c- Second_Date_Time_c )* 24 * 60, 60 ), 0))

& " Minutes "