Skip to Content

# Rule to determine time difference in Hour/Minute/Second between two input Times in SuccessFactors EC

## Rule to determine time difference in Hour/Minute/Second between two input Times in SuccessFactors EC

Author: Sandip Biswas, Certified Employee Central Consultant

Background: In SuccessFactors sometime we may create two custom fields (Data Type – Time) in standard or custom MDF & also we may need to calculate the difference between these two time fields.

Say for example we have created two custom Time fields named as Start Time & End Time in custom MDF; Start Time value is 17:00:00 & End Time value is 19:00:00. For some calculation we need the difference between these two times. As per the given example the result should be 2 hours or 120 minutes.

In the standard business rule function, we don’t have any available standard function which will accept the time values as input will provide the result of the time difference in decimal format (Hours/Minutes/Seconds).

But there are some other standard functions which can be used to determine the difference between these two times with some simple logic in business rule.

Sample Fields in MDF: cust_StartTime & cust_EndTime with Data Type Time. Sample Rule: Explanation of the rule: In rule engine we have standard function “Calculate Duration Between Two Date Time Values” which is used to determine the difference between two fields (in Seconds) where data type is “DateTime”.

Sample DateTime Field in SF: DateTime data type is combination of date and time, it does not include time only. We can use this standard function to fulfil our requirement.

In the rule we have data type Time as input field. From the Time Data type first we are creating DateTime Data with the help of rule function “Create Date Time”.  In the Create Date Time we are passing the date as Today & offset as 0.

After that “Calculate Duration in Seconds Between Two Date Time Values” rule function is used to determine the duration in seconds. Then we are dividing calculated seconds by 60 to determine the duration in minutes. We can divide it further by 60 to determine the duration in Hour.

Be the first to leave a comment
You must be Logged on to comment or reply to a post.