There are a lot of ways to solve this problem. Instinctively, our brains want to subtract two time values just as we do two integers. But the "borrow" can get a little bit messy because the time format of Hh:Mm. When subtracting column m, if a borrow is necessary we decrement M and add 10 the smaller value. When subtracting column M, we decrement h and add 6 to M.

It becomes an excercise in programming that we learn to avoid.

The easiest way is to convert each time value to a common integer value. In this case, the number of minutes per day (24*60=1440) works well, so does the number of seconds per day (24*60*60=86400). Then subtract the two integers and convert back to HH:mm

Here are the formulas. Since this sounds like homework, you'll have to plug them in yourself:

MinuteValue = Hours * 60 + Minutes; // Convert HH:MM to minutes

Hh = MinuteValue / 60;

Mm = MinuteValue % 60;

Good Luck,

Kent