Skip to main content
I have a custom field formula called "Shift length" which is calculating the time between 2 date/time fields. Code is shown below:

 

(floor(( Shift_Time_of_End__c - Shift_Time_of_Start__c )*24)) 

 

 

(((((Shift_Time_of_End__c - Shift_Time_of_Start__c )*24)-floor((Shift_Time_of_End__c - Shift_Time_of_Start__c )*24))*60)/100)

 

I now need to have a custom number field called "Break taken" that is manually inputted by the user to reflect the time of the break. Eg 1.00 is 1 hour or 1.20 is 1hr 20 mins.

 

I then need to deduct the "break taken" field from the "shift length" field to give me a total called for example "Hours to be paid". 

 

How can I get the number field to reflect the correct time? Whilst it works in some scenarios by simply having a minus formula, in others it doesn't. Eg if shift length returns 6.15 (eg 6hrs 15 mins) and if the break taken is 0.45 (eg 45 mins) the formula returns 5.70 instead of 5.30 (which would be 5hrs 30 mins.

 

Thanks

 

 
9 answers
  1. Jun 1, 2017, 9:13 AM
    Hi Matt,

     

    Please give this a shot.

    FLOOR((((Shift_Time_of_End__c - Shift_Time_of_Start__c)*24*60) -

    (

    (FLOOR(break_taken__c)*60) +

    (break_taken__c - FLOOR(break_taken__c))*100

    ))/60)+

    MOD(

    (((Shift_Time_of_End__c - Shift_Time_of_Start__c)*24*60) -

    (

    (FLOOR(break_taken__c)*60) +

    (break_taken__c - FLOOR(break_taken__c))*100

    )),60)/100

     

     
0/9000