Properly calculating time differences
Posted on 2004-10-12
Before I get too involved in 'the wrong way' here, let me here some advice from you guys.
I have a time recording application that simply tracks time for my users.
I have two dtp items (dtpTime(0) & (1) - start and stop respectively).
Now, in my click event, I want to calculate the difference between the two.
However, if dtpTime(0) is valued at 12:00 AM, I simply want my total to be whatever is in dtpTime(1)
So, if a user sets
(0) = 8:00 AM
(1) = 8:30 AM
I want (I think) the return to be .5
There will be really rare occasions (and I haven't convinced myself yet to place it back in) where a timer function will allow these values to be set according to a stopwatch type recording for both start and stop values.
However, most values will probably be full, half or quarter hour (1, 1.25, 1.5, 1.75, etc)
Am I going about this the right way here?
The local db will probably store the actual Times (1:00PM and 1:30PM) as well as the difference (.5 or 30 mins).
But the master database is only concerned with the total (.5 or 30 mins).
I need to keep the range local in case the user ever wants to change the timeframe - but once submitted to the master, I have no need, nor will allow, these changes...
Any advice before I get my hands dirty? : )