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.
+ Start a Discussion
m pandeym pandey 

how to calculate the time duration hours...?

stime 5:00 AM
etime 6:00 PM

stime in text frmt
etime in text frmt

i want the total hours in time between

Hi pandey,

Better use the Date/Time field type and then  you can refer the following code to find the difference(first get the stime to a date variable called stime and etime to a date variable called etime),
Long dt1Long = stime.getTime();
Long dt2Long =etime.getTime();
Long milliseconds = dt2Long - dt1Long;
Long seconds = milliseconds / 1000;
Long minutes = seconds / 60;
Long hours = minutes / 60;
Long days = hours / 24;
vishnu Rvishnu R
hi gopal,

take two date/time  fields

>>> (( shobithapp__End_Date__c - shobithapp__Start_Date__c) *24) == this formula will give you total no of Hours between two date/time.
>>> (( shobithapp__End_Date__c - shobithapp__Start_Date__c )*24*60)== this formula will give you total number of minutes between two date/time.

hope this helps you..mark it as best answer if this resolved your issue..