How to Calculate Time Difference Betweens Two Input Times

Currently, there is no available business function to get time difference. The following event rules logic can be considered :

  1. Convert Input TimeA from HHMMSS into Seconds (Time A)
  2. Convert TimeA from HHMMSS into Seconds (Time B)
  3. Subtract A to B to calculate time Between
  4. Convert Seconds to HHMMSS format

 Parameters: 

  • (IN) FC_mnTime_A
  • (IN) FC_mnTime_B
  • (OUT) FC_mnTime_BetweenTime_Seconds
  • (OUT) FC_mnTime_BetweenTime_HHMMSS

Possible Implementation:

1. Convert TimeA from HHMMSS into Seconds (Time A)

If FCmnTimeA is not equal to <Blank>
Or FCmnTimeA is not equal to <NULL>
   VA evtmnHours01 = ([FCmnTimeA]/10000)-(mod([FCmnTimeA],10000)/10000)
   VA evt
mnMinSec01 = mod([FCmnTimeA],10000)
   VA evtmnMinutes01 = ([VA evtmnMinSec01]/100)-(mod([VA evtmnMinSec01],100)/100)
   VA evt
mnSeconds01 = [VA evtmnMinSec01]-([VA evtmnMinutes01]100)
   VA evt_mnTimeInSeconds01 = ((([VA evt_mnHours01]
60)60)+([VA evt_mnMinutes01]60))+[VA evt_mnSeconds01]
End If
 

  1. Convert TimeA from HHMMSS into Seconds (Time B)

If FCmnTimeB is not equal to <Blank>
Or FCmnTimeB is not equal to <NULL>
  VA evtmnHours02 = ([FCmnTimeB]/10000)-(mod([FCmnTimeB],10000)/10000)
  VA evt
mnMinSec02 = mod([FCmnTimeB],10000)
  VA evtmnMinutes02 = ([VA evtmnMinSec02]/100)-(mod([VA evtmnMinSec02],100)/100)
  VA evt
mnSeconds02 = [VA evtmnMinSec02]-([VA evtmnMinutes02]100)
  VA evt_mnTimeInSeconds02 = ((([VA evt_mnHours02]
60)60)+([VA evt_mnMinutes02]60))+[VA evt_mnSeconds02]
End If
 

  1. Subtract from A to B to calculate time between
    FCmnTimeBetweenTimeSeconds = abs(([VA evtmnTimeInSeconds01]-[VA evt_mnTimeInSeconds02]))

  2. Convert Seconds to HHMMSS format

VA evtmnSecondsOutput = mod([FCmnTimeBetweenTimeSeconds],60)
VA evt
mnHourMinuteoutput = [FCmnTimeBetweenTimeSeconds]-[VA evtmnSecondsOutput]
VA evtmnMinuteOutput = mod(([VA evtmnHourMinuteoutput]/60),60)
VA evtmnHourOutput = (([FCmnTimeBetweenTimeSeconds]-([VA evtmnMinuteOutput]*60))-[VA evtmnSecondsOutput])/3600
FCmnTimeBetweenTimeHHMMSS
 = [VA evtmnHourOutput]10000+[VA evt_mnMinute_Output]100+[VA evtmnSecondsOutput]
 
Source: Oracle ID 662294.1

Leave a Reply