+ Start a Discussion
VSK98VSK98 

Calculate the hours between two datetime fields

Hi All,
I have created the formula field for calculating the hours between two datetime fields ........But it not showing exact hrs......My Piece of code
 
TEXT(DATEVALUE (Closed) - DATEVALUE (Open)- 0.2916)
 
IF(
Floor(DATEVALUE (closed)-DATEVALUE (open))*24)>9
(Floor((DATEVALUE (closed)-DATEVALUE (open))*24)),
"0"& TEXT(Floor((DATEVALUE (closed)-DATEVALUE (open))*24))
)

I tried both .......bt i couldn't get it


Pls suggest me

ADV THNXS
VSK98
Harsh Aditya 21Harsh Aditya 21
Hi VSK98,

Please try the below formula:
 
(Closed - open) *24

Harsh Aditya
AshlekhAshlekh
Hi.

I've created a Text type formula and able to see the difference.

I took this case - Calculate the time difference between created record and lastmodified record.

Here is formula.
 
TEXT(FLOOR((LastModifiedDate - CreatedDate)*24)) &' Hr '& TEXT(FLOOR(((((LastModifiedDate - CreatedDate)*24)-FLOOR((LastModifiedDate - CreatedDate)*24))*60)))&' Mins'

-Thanks
Ashlekh Gera
David SchmitkeDavid Schmitke
Thanks for this solutuon Ashlekh, very helpful! 
WillSh1WillSh1
Hi Ashlekh,

Thanks, great formula. Were you able to exclude weekends?

Cheers
Will
Sibluself SibluselfSibluself Sibluself
Hello
Thank you for help . (https://www.my-accountaccess.com/)
Jayesh KshirsagarJayesh Kshirsagar
And can we calculate seconds and miliseconds also ?
if yes then what will be the formula to calculate seconds and miliseconds.