A bit of clarification. You want to add start time and duration, then return only the minutes portion of the result? If so, then w/o any code or algorithms, just looking at the test data, I can't see how the expected result on the first one could be 20... 40 + 45 = 85 = 1h25m, so result should be 25. The rest seem logical/correct. Or I could be misunderstanding the requirement. Cheers, -Neil. -----Original Message----- From: pic microcontroller discussion list [mailto:PICLIST@MITVMA.MIT.EDU]On Behalf Of cdb Sent: Thursday, June 27, 2002 6:48 AM To: PICLIST@MITVMA.MIT.EDU Subject: [PIC]: Algorithm help Hello all, I need some help working out an elapsed time routine. I'm loath to ask for help as I hope to enter the final thing in the competition, but-- I have a start time (in minutes) and a duration time(in minutes) and I always get a maths error at one point of testing. So far I have two algorithms and both fail at the same time difference - could some poke me in the right direction? Alg 1. IF StartMinutes + Duration Minutes > 60 then Mdiff=60- StartMinutes Off=DurationMinutes-Mdiff OTHERWISE just add the two together Alg 2. IF start etc then off= (startM's+DurM's )-60 OTHERWISE etc. The test data (ignore hours they work ) in minutes only. Duration times are in 15min increments Start Dur Expected Result 40 45 20 50 30 20 50 15 5 55 15 10 50 45 35 All the results except the first one match, the first one matches if I use15 or 30 minutes as the duration time, I just can't fathom where I need to make an adjustment. All pointers gratefully received. Colin -- cdb, cdb@barnard.name on 31/03/2002 -- cdb, bodgy1@optusnet.com.au on 27/06/2002 -- http://www.piclist.com hint: PICList Posts must start with ONE topic: [PIC]:,[SX]:,[AVR]: ->uP ONLY! [EE]:,[OT]: ->Other [BUY]:,[AD]: ->Ads -- http://www.piclist.com hint: PICList Posts must start with ONE topic: [PIC]:,[SX]:,[AVR]: ->uP ONLY! [EE]:,[OT]: ->Other [BUY]:,[AD]: ->Ads