To do this, you need all of your input to be in the same domain. Here, you're working with input in two different domains, which I'll call decimal
and time
.
The decimal
domain (I'll assume a precision/scale of 2) goes from 0.00 - 0.99 before rolling over to 1.00.
The time
domain goes from 0.00 - 0.59 before rolling over to 1.00
Getting the fractional part of your Billable Hours can be done in a formula field by using MOD(Billable_Hours__c, 1)
From there, converting from the time
domain to the decimal
domain is as simple as multiplying by 10/6. This is fairly basic math (unit conversion), so I won't go over it in detail.
When you're done with your work in the decimal
domain, you want to covert back to the time
domain by multiplying by 6/10. You only want to do this for the fractional part though.
In the end, your formula should look something like this
FLOOR(
(Budgeted_Hours__c - FLOOR(Billable_Hours__c) - (MOD(Billable_Hours__c, 1) * 10/6))
)
+
(
MOD((Budgeted_Hours__c - FLOOR(Billable_Hours__c) - (MOD(Billable_Hours__c, 1) * 10/6)), 1) * 6/10
)
There really isn't a way to get around the duplication in the resulting formula here. This is probably a sign that you'd be better off doing this in Apex rather than a formula field...but there it is.
+edit:
If your compiled formula size is too large, then either one, or both, of your fields is/are a formula field itself. It doesn't take too much, when referencing formula fields in another formula field , to push yourself over the compiled size limit.
At that point, you'd have 2 options:
- Work on making your other formula fields more efficient
- Create a workflow rule to perform a field update, taking the value of
Billable_Hours__c
or Budgeted_Hours__c
, and sticking them into new number fields (that you'd need to create), and using those new number fields in the formula in place of the old, formula fields
Again, I must stress that doing this through Apex is likely a much better solution. You should seriously consider this if it is an available option.
You can take help from SUBSTITUTE(text, old_text, new_text)
function . for example
TRIM( SUBSTITUTE(Target Kindergarten 1, Target, ''));
it will give you
Kindergarten 1
This code will only work if you have fixed text value Target.
Best Answer
Use the following formula. It handles numbers up to 999,999,999.99 and rounding to 2 decimals, adjustable.