Anda di halaman 1dari 11

Subtraction of Hours and Minutes How to subtract hours and minutes.

If the number of minutes being subtracted is more than the original minutes, do the following: o Subtract 1 from the original number of hours.
o

Increase the number of original minutes by 60.

Subtract the minutes. Subtract the hours.

Example: What is 4 hours 11 minutes minus 2 hours 47 minutes.

The original number of minutes (11) is less than the 47 minutes being subtracted so: o Subtract 1 from the original number of hours. (4 hours - 1 hour = 3 hours)
o

Increase the number of minutes by 60. (11 minutes + 60 minutes = 71 minutes)

Subtract the minutes. (71 minutes - 47 minutes = 24 minutes) Subtract the hours. (3 hours - 2 hours = 1 hour) Answer: 1 hour 24 minutes

Subtraction of Minutes and Seconds How to subtract minutes and seconds

If the number of seconds being subtracted is more than the original seconds, do the following: o Subtract 1 from the original number of minutes.
o

Increase the number of original seconds by 60.

Subtract the seconds. Subtract the minutes.

Example: What is 4 minutes 11 seconds minus 2 minutes 47 seconds.

The original number of seconds (11) is less than the 47 seconds being subtracted so:

o o

Subtract 1 from the original number of minutes. (4 minutes 1 minute = 3 minutes) Increase the number of seconds by 60. (11 seconds + 60 seconds = 71 seconds)

Subtract the seconds. (71 seconds - 47 seconds = 24 seconds) Subtract the minutes. (3 minutes - 2 minutes = 1 minute) Answer: 1 minute 24 seconds

Subtraction rules for DATE, TIME, and TIMESTAMP The only arithmetic operation that can be performed on datetime values is subtraction. The subtraction operator can be used with datetime values only when both operands are dates, or both operands are times, or both operands are timestamps. DATE The result of subtracting one date (DATE2) from another (DATE1) is a date duration that specifies the number of years, months, and days between the two dates. The data type of the result is DECIMAL(8,0). For example, the result of DATE('3/15/2000') DATE('12/31/1999') is 00000215 (a duration of 0 years, 2 months, and 15 days). If DATE1 is greater than or equal to DATE2, DATE2 is subtracted from DATE1. If DATE1 is less than DATE2, however, DATE1 is subtracted from DATE2, and the sign of the result is made negative. The following procedural description clarifies the steps involved in the operation result = DATE1 - DATE2. If DAY(DATE2) <= DAY(DATE1) then DAY(RESULT) = DAY(DATE1) - DAY(DATE2). If DAY(DATE2) > DAY(DATE1) then DAY(RESULT) = N + DAY(DATE1) - DAY(DATE2) where N = the last day of MONTH(DATE2). MONTH(DATE2) is then incremented by 1. If MONTH(DATE2) <= MONTH(DATE1) then MONTH(RESULT) = MONTH(DATE1) - MONTH(DATE2). If MONTH(DATE2) > MONTH(DATE1) then MONTH(RESULT) = 12 + MONTH(DATE1) - MONTH(DATE2).

YEAR(DATE2) is then incremented by 1. YEAR(RESULT) = YEAR(DATE1) - YEAR(DATE2). TIME The result of subtracting one time (TIME2) from another (TIME1) is a time duration that specifies the number of hours, minutes, and seconds between the two times. The data type of the result is DECIMAL(6,0). For example, the result of TIME(11:02:26) TIME(00:32:56) is 102930 (a duration of 10 hours, 29 minutes, and 30 seconds). If TIME1 is greater than or equal to TIME2, TIME2 is subtracted from TIME1. If TIME1 is less than TIME2, however, TIME1 is subtracted from TIME2, and the sign of the result is made negative. The following procedural description clarifies the steps involved in the operation result = TIME1 - TIME2. If SECOND(TIME2) <= SECOND(TIME1) then SECOND(RESULT) = SECOND(TIME1) - SECOND(TIME2). If SECOND(TIME2) > SECOND(TIME1) then SECOND(RESULT) = 60 + SECOND(TIME1) - SECOND(TIME2). MINUTE(TIME2) is then incremented by 1. If MINUTE(TIME2) <= MINUTE(TIME1) then MINUTE(RESULT) = MINUTE(TIME1) - MINUTE(TIME2). If MINUTE(TIME1) > MINUTE(TIME1) then MINUTE(RESULT) = 60 + MINUTE(TIME1) - MINUTE(TIME2). HOUR(TIME2) is then incremented by 1. HOUR(RESULT) = HOUR(TIME1) - HOUR(TIME2). TIMESTAMP The result of subtracting one timestamp (TS2) from another (TS1) is a timestamp duration that specifies the number of years, months, days, hours, minutes, seconds, and microseconds between the two timestamps. The data type of the result is DECIMAL(20,6). If TS1 is greater than or equal to TS2, TS2 is subtracted from TS1. If TS1 is less than TS2, however, TS1 is subtracted from TS2 and the sign of the result is made negative. The following procedural description clarifies the steps involved in the operation result = TS1 - TS2: If MICROSECOND(TS2) <= MICROSECOND(TS1) then MICROSECOND(RESULT) = MICROSECOND(TS1) - MICROSECOND(TS2).

If MICROSECOND(TS2) > MICROSECOND(TS1) then MICROSECOND(RESULT) = 1000000 + MICROSECOND(TS1) MICROSECOND(TS2) and SECOND(TS2) is incremented by 1. The seconds and minutes part of the timestamps are subtracted as specified in the rules for subtracting times. The date part of the timestamps is subtracted as specified in the rules for subtracting dates.

9. Comparison and Subtraction of Time Intervals

The Easy Case - Conversions not needed Here are two time intervals in cosmetic normal formal T1 = 6 hours 35 minutes and 15 seconds T2 = 8 hours 45 minutes and 30 seconds The second time interval T2 has more hours, more minutes and seconds than the first T1. So it is larger. The subtraction T2 = 8 hours 45 minutes and 30 seconds T1 = 6 hours 35 minutes and 15 seconds T2 - T1 = 2 hours 10 minutes and 15 seconds __

suggests T2 is 2 hours 10 minutes and 15 seconds more than T1. Let us check that by an addition: 2 hours 10 minutes and 15 seconds T1 = 6 hours 35 minutes and 15 seconds + 8 hours 45 minutes and 30 seconds = T2 Harder Cases - Conversions Needed Here are two more time intervals T1 = 7 hours 35 minutes and 15 seconds T2 = 5 hours 45 minutes and 30 seconds The first time interval T1 has 2 more hours than the second T2. Just one of those extra hours by itself is larger than the minute and second part of the other time interval T2. So in this case, the first time interval is more than (larger than) the second. Subtraction will say how much more.

The first time interval T1 in its minutes and second portion has fewer minutes and fewer seconds than the other time interval T2 . So the first column method for subtraction introduced above would have us write: The subtraction T1 = 7 hours 35 minutes and 15 seconds T2 = 5 hours 45 minutes and 30 seconds T2 - T1 = 2 hours ?? minutes and ?? seconds __

If we avoid negative numbers or counts, we will have difficulty with the seconds and minute entries in this subtraction. But the first time interval T1 has 2 more hours than the second T2. Just one of those extra hours by itself is larger than the minute and second part of the other time interval T2. That suggests a conversion: 1 hour = 59 minutes and 60 seconds and so 7 hours = 6 hours, 59 minutes and 60 seconds. Now T1 = 7 hours 35 minutes and 15 seconds = 6 hours, 59 minutes and 60 seconds + 35 minutes and 15 seconds We want to subtract T2 = 5 hours 45 minutes and 30 seconds from the latter. T1 = 6 hours, 59 minutes and 60 seconds + 35 minutes and 15 seconds T2 = 5 hours 45 minutes and 30 seconds __ T1 - T2 = 1 hour 14 minutes and 30 seconds + 35 minutes and 15 seconds That latter gives T1 - T2 = 1 hour 49 minutes and 45 seconds

The latter gives how much, the first time length T1 is more than the other time interval T2. Let us check that: 1 hour 49 minutes and 45 seconds T2 = 5 hours 45 minutes and 30 seconds + 7 hours, 35 minutes and 15 seconds = T1 1 1 Observe the presence of carries in the minute and hours columns. The foregoing calculations suggest a column method for subtraction when conversions are needed. First, write T1 = 7 hours 35 minutes and 15 seconds <======= The extra line.

T2 = 5 hours 45 minutes and 30 seconds

__

as before, but with an extra line. The extra line is needed. We will cross-out the 7 hours on the top line, and replace its by 6 hours, 59 minutes and 60 seconds on the second line. That gives T1 = 7 hours 35 minutes and 15 seconds 6 hours, 59 minutes and 60 seconds T2 = 5 hours 45 minutes and 30 seconds

<======= The extra line. __

The task now is to subtract the third line from the top two lines. T1 = 7 hours 35 minutes and 15 seconds 6 hours, 59 minutes and 60 seconds T2 = 5 hours 45 minutes and 30 seconds T1 - T2 = 1 hour 49 minutes and 45 seconds

__

as before. Here 15 + 60 - 30 = 15 + 30 = 45 gives the second count 35 + 59 - 45 = 35 + 14 = 49 gives the minute count 6 - 5 = 1 gives the hour count The result is the same as before. Note the extra line is present if a conversion is needed. Worked Examples: Take the shorter time interval away from the longer time interval. Example A. 23 hours 18 minutes 17 seconds versus 34 hours 45 minutes 25 seconds Solution: The second time interval is larger as it has more hours than than first. The difference is give by the calculation: hours 34 23 9 mins secs 45 25 18 17 27 8

No extra line is needed here because no conversions are needed. The second time interval is 9 hours, 27 minutes and 8 seconds more than the first. Check that in place by seeing i if the sum of the bottom two rows in the above column method for subtraction equals the first.

Example B. 50 hours 23 minutes 17 seconds versus 34 hours 25 minutes 25 seconds. Solution: The first time interval is larger as it has more hours than than first. The difference is give by first writing hours 50 23 mins secs 23 17 25 25 -

with an extra line since conversions will be needed in the minute and seconds column. Now in place, cross-out the 50 and replace it by an entry of 49 hours, 59 minutes and 60 seconds in line 2. That should give you hours 50 49 23 mins 23 59 25 secs 17 60 25 -

Now continue the calculation in place to obtain the following: hours 50 49 23 26 Work: mins secs 23 17 59 60 25 25 57 52 (line 1) (line 2) (line 3) (line 4)

17 + 60 - 25 = 17 + 35 = 52 23+ 59 - 25 = 23 + 37 = 57 49 - 26 = 23

The longer time interval should be 26 hours, 57 minutes and 52 seconds more than the first. Finally, check that in place by verifying the original line 1 (no cross-out) is the sume of lines 3 and 4 Example C. 30 hours 35 minutes 13 seconds versus 30 hours 20 minutes 25 seconds. Solution: Again, the first time interval is larger as it has more minutes than than first. The difference is calculated by first writing hours 30 mins secs 35 13

30

20

25 -

with an extra line since conversions will be needed in the minute and seconds column. Now in place, cross-out the 35 in the minute column and replace it by an entry of 34 minutes and 60 seconds in line 2. That should give you hours mins secs 30 35 13 34 60 30 20 25 Now continue the calculation in place to obtain the following: hours 30 30 Work: mins 35 34 20 14 secs 13 (line 1) 60 (line 2) 25 (line 3) 48 (line 4)

13 + 60 - 25 = 13 + 35 = 48 34 - 20 = 14

The longer time interval should be 14 minutes and 48 seconds more than the first. Finally, check that in place by verifying the original line 1 (no cross-out) is the sum of lines 3 and 4 Example D. 55 hours 43 minutes 35 seconds versus 35 hours 13 minutes 55 seconds. Solution: Again, the first time interval is larger as it has more hours than than first. The difference is calculated by first writing hours mins secs 55 43 35 35 13 55 -

with an extra line since conversions will be needed in the seconds column. No conversions are needed elsewhere. The first line has more minutes than the last line. Now in place, cross-out the 43 in the minute column and replace it by an entry of 42 minutes and 60 seconds in line 2. That should give you hours 55 35 mins 43 42 13 secs 35 60 55 -

Now continue the calculation in place to obtain the following: hours mins 55 43 42 35 13 20 29 Work: secs 35 60 55 40

35 + 60 - 55 = 35 + 5 = 40 42 - 13 = 29

The longer time interval should be 20 hours, 29 minutes and 40 seconds more than the first. Finally, check that in place by verifying the original line 1 (no cross-out) is the sum of the last two lines.
Example D - Revisited 55 hours 43 minutes 35 seconds versus 35 hours 13 minutes 55 seconds.

Solution: Again, the first time interval is larger as it has more hours than than first. The difference is calculated by first writing hours mins secs 55 43 35 35 13 55 -

with an extra line since conversions will be needed in the seconds column. No conversions are needed elsewhere. In this second version of Example D, we will convert 55 hours into 54 hours, 59 minutes and 60 seconds. That is not necessary because 43 minutes and 35 seconds is longer than 13 minutes and 55 seconds, and hence conversion of 43 minutes into 42 minutes and 60 seconds was good enough (and quicker). We doing this to compare and contrast the two routes for obtaining a solution. You need the experience. The first line has more hours than the last line. Now in place, cross-out the 55 in the hour column and replace it by an entry of 54 hours, 59 minutes and 60 seconds in line 2. That should give you hours mins secs 55 43 35 54 59 60 35 13 55 -

Now continue the calculation in place to obtain the following: hours 55 54 35 20 1 mins 43 59 13 29 secs 35 60 55 40

Work:

35 + 60 - 55 = 35 + 5 = 40 as before 43 + 59 -13 = 43 + 46 = 89 or 1 hour and 29 minutes (that gives a carry of 1 hour to add into the hours column 1+ 54 - 35 = 1 + 19 = 20

Again, the time interval should be 20 hours, 29 minutes and 40 seconds more than the first. In this second approach, the conversion of 55 hours into 54 hours, 59 minutes and 60 seconds was not wrong, but it the effect of introducing the conversion of 89 minutes into the answer. Without the conversion of 89 minutes into 1 hour and 29 minutes, the above calculation would have given hours mins secs 55 43 35 54 59 60 35 13 55 19 89 40 or 19 hours, 89 minutes and 40 seconds as a result, correct except it is not in cosmetic normal form. Example E. 25 hours 45 minutes 10 seconds versus 40 hours 18 minutes 55 seconds versus . Solution: The second time interval has more hours than the first. So it is larger. The difference is calculated by first writing hours 40 25 mins secs 18 55 45 10 -

with an extra line since conversions will be needed. Now in place, 55 secs - 10 secs gives 45 secs. In place that gives hours 40 25 mins secs 18 55 45 10 45 -

Now in place, cross-out the 40 in the hour column and replace it by an entry of 39 hours and 60 minutes in the extra line. hours 40 39 25 mins secs 18 55 60 45 10 45

Now continue the calculation in place to obtain the following: hours 40 39 25 14 Work: mins secs 18 55 60 45 10 33 45 18 + 60 - 45 = 18 + 15 = 33 39 - 25 = 14

The longer time interval should be 14 hours, 33 minutes and 45 seconds more than the other. Finally, check that in place by verifying the original line 1 (no cross-out) is the sum of the last two. Remark: We could use negative numbers here.

Anda mungkin juga menyukai