How do I calculate elapsed minutes using combination of three time fields
Posted on 2006-05-15
I have three time fields: StartTime, EndTime, ElapasedMinutes. I need these three fields to work as a collective unit. I've tried various combinations, but I can't come across an elegant solution. I know I can't be the first to come up against this.
I have three scenarios:
1) Times are manually entered into the StartTime and EndTime fields in military time (e.g., 10:45 and 12:45). The Elapsed minutes are automatically calculated (i.e., 120).
2) The EndTime is entered (e.g., 12:45) and the Elapsed minutes (e.g.. 120). The StartTime is automatically caluclated and completed (i.e., 10:45).
3) The StartTime is entered (e.g., 10:45) and the Elapsed minutes (e.g.. 120). The EndTime is automatically caluclated and completed (i.e., 12:45).
All these calculations should occur on onChange events, so if any one of the fields is altered the other two fields are automatically computed. That way, the user only needs to complete 2 of the 3 fields--whichever fits in with the workflow they are handling.