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
Keith ShapiroKeith Shapiro 

Date/Time field subtraction.

I've found some things here but not something I can get to work.

2 fields Join_Time__c, Leave_Time__c I want to produce a number in minutes by subtracting the time they joined from the time they left a webinar either 42(NN) or HH:MM will be acceptable. I need to know the field type to use and the formula. I'm not finding what I'm looking for that will work for some reason.

Thanks!
Best Answer chosen by Keith Shapiro
Leslie  KismartoniLeslie Kismartoni
Hi,

Create both of the those fields as Date/Time fields. (I called mine End__c and Start__c)

Now, create an additional formula custom field, I called mine "Difference". This field should return a text type.
The body of the formula will be:
TEXT((End__c - Start__c) * 1440)

This will return the number of minutes between End and Start... 

All Answers

Leslie  KismartoniLeslie Kismartoni
Hi,

Create both of the those fields as Date/Time fields. (I called mine End__c and Start__c)

Now, create an additional formula custom field, I called mine "Difference". This field should return a text type.
The body of the formula will be:
TEXT((End__c - Start__c) * 1440)

This will return the number of minutes between End and Start... 
This was selected as the best answer
Leslie  KismartoniLeslie Kismartoni
(BTW - you could add " minutes" or whatever units to the end of that if you wanted...)
Keith ShapiroKeith Shapiro
What if I wanted it to be a number? is that possible? This works by the way :)
YuchenYuchen
If you want it to be in number, you can just remove the TEXT part from Leslie's formula, so it will be:

(Leave_Time__c - Join_Time__c)*1440
Leslie  KismartoniLeslie Kismartoni
Yuchen is correct that changing the formula field type to number will work. You may end up with some Decimals... If you liked the solution, could you mark it as a solution?

Many thanks!
Keith ShapiroKeith Shapiro
You guys are awesome! Both work, number is what I needed. It's a solution!